
    ܙdwg                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z
d dlZd dlmZ d dlZd dlmZ d dlZd dlmZmZ d dlZd dlmZmZ d dlZd dlZd dlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ d dl%m	Z	m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. d d	l/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 d d
l6m7Z7 d dl8m9Z9 d dl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA d dlBmCZD d dlEmFZF d dlGmHZHmIZImJZJmKZK d dlLmMZMmNZN d dlOmPZP d dlQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^ d dl_m`Z` d dlEmaZa d dl%mbZb d dlcZcd dldZdeX G d deR                      Ze edjf         ejg                    dvd          ZhdZidZj edd          Zkd Zle^ G d d eR                      Zmd! Znd" Zod# Zpd$ Zqd% Zrd& Zsd' Ztd( Zud) Zvd* Zwd+ ZxdUd,Zyd- Zz G d. d/e{          Z|eX G d0 d1em                      Z}eX G d2 d3em                      Z~eX G d4 d5em                      Z G d6 d7eR          ZeX G d8 d9em                      ZeX G d: d;eTem                      ZeX G d< d=em                      ZeX G d> d?em                      ZeX G d@ dAem                      ZeX G dB dCem                      ZeX G dD dEem                      Z G dF dGem          ZeX G dH dIe                      ZeX G dJ dKe                      ZeX G dL dMeR                      ZeXeh G dN dOe                                  ZeX G dP dQeR                      ZeX G dR dSeR                      ZedTk    r edj                     dS dS )V    )sqrtNreducerandn)defaultdict
namedtuple)cyclechain)njitprangeparallel_chunksizeget_parallel_chunksizeset_parallel_chunksizeset_num_threadsget_num_threadstypeof)
typestypingerrorsirrewritestyped_passesinline_closurecallconfigcompilercpu)overload_methodregister_modeltypeof_implunboxNativeValuemodels)
cpu_target)type_annotations)find_callnameguardbuild_definitionsget_definition
is_getitem
is_setitemindex_var_of_get_setitem)empty_inferred)ByteCodeIter)compile_isolatedFlagsCompilerBaseDefaultPassBuilder)register_passAnalysisPass)IRLegalization)TestCasecaptured_stdoutMemoryLeakMixinoverride_env_config
linux_onlytagskip_parfors_unsupported_32bit
needs_blasneeds_lapackdisabled_testskip_unless_scipyneeds_subprocess)register_jitable)_fix_LOAD_GLOBAL_arg)utilsc                       e Zd ZdZ ej                    dk    rdndZ	 d Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestParforsRunnerFaarch64i  i  c                     | j         }|                                                     d          d                             d          d         }|                     ||| j                   d S )N._)test_module
test_classtimeout)
__module__idsplitsubprocess_test_runner_TIMEOUT)selfthemodtest_clazz_names      8lib/python3.11/site-packages/numba/tests/test_parfors.pyrunnerzTestParforsRunner.runnerP   sk    ''))//#..r288==bA##/>,0M 	$ 	; 	; 	; 	; 	;    c                 .    |                                   d S NrY   rU   s    rX   test_TestParforBasicz&TestParforsRunner.test_TestParforBasicX       rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforNumericalMiscz.TestParforsRunner.test_TestParforNumericalMisc[   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforNumPyz&TestParforsRunner.test_TestParforNumPy^   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsz"TestParforsRunner.test_TestParforsa   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsBitMaskz)TestParforsRunner.test_TestParforsBitMaskd   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsDiagnosticsz-TestParforsRunner.test_TestParforsDiagnosticsg   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsLeaksz'TestParforsRunner.test_TestParforsLeaksj   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsMiscz&TestParforsRunner.test_TestParforsMiscm   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsOptionsz)TestParforsRunner.test_TestParforsOptionsp   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsSlicez'TestParforsRunner.test_TestParforsSlices   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestParforsVectorizerz,TestParforsRunner.test_TestParforsVectorizerv   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestPrangeBasicz&TestParforsRunner.test_TestPrangeBasicy   r`   rZ   c                 .    |                                   d S r\   r]   r^   s    rX   test_TestPrangeSpecificz)TestParforsRunner.test_TestPrangeSpecific|   r`   rZ   N)__name__rP   __qualname___numba_parallel_test_platformmachinerT   rY   r_   rb   rd   rf   rh   rj   rl   rn   rp   rr   rt   rv   rx    rZ   rX   rG   rG   B   s        " (x'))Y66ttDH
; ; ;                            rZ   rG   )i386x86_64zx86 only test      TestNamedTuplepart0part1c                     dS )z
    Used with check_arq_equality to indicate that we do not care
    whether the value of the parameter at the end of the function
    has a particular value.
    Nr~   abs     rX   null_comparerr      s	     	DrZ   c                        e Zd ZdZdZ fdZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZddZddZd Zd Zd Zd Z xZS )TestParforsBasez
    Base class for testing parfors.
    Provides functions for compilation and three way comparison between
    python functions, njit'd functions and parfor njit'd functions.
    Fc                    t                      | _        d| j        _        t                      | _        t	          j        d          | j        _        d| j        _        t                      | _        t	          j        d          | j        _        d| j        _        t	          j        d          | j        _	         t          t          |           j        |  d S )NT)r0   cflagsnrtpflagsr   ParallelOptionsauto_parallelfast_pflagsFastMathOptionsfastmathsuperr   __init__)rU   args	__class__s     rX   r   zTestParforsBase.__init__   s    gg gg$'$7$=$=! !77),)<T)B)B&#$'$7$=$=!-ot$$-t4444rZ   c                 &    t          |||          S N)flags)r/   )rU   funcsigr   s       rX   _compile_thiszTestParforsBase._compile_this   s    c7777rZ   c                 <    |                      ||| j                  S r   )r   r   rU   r   r   s      rX   compile_parallelz TestParforsBase.compile_parallel       !!$4;!???rZ   c                 <    |                      ||| j                  S r   )r   r   r   s      rX   compile_parallel_fastmathz)TestParforsBase.compile_parallel_fastmath   s     !!$43C!DDDrZ   c                 <    |                      ||| j                  S r   )r   r   r   s      rX   compile_njitzTestParforsBase.compile_njit   r   rZ   c                     t          d |D                       }|                     ||          }|                     ||          }||fS )Nc                 6    g | ]}t          j        |          S r~   numbar   .0xs     rX   
<listcomp>z/TestParforsBase.compile_all.<locals>.<listcomp>        333U\!__333rZ   )tupler   r   )rU   pyfuncr   kwargsr   cpfunccfuncs          rX   compile_allzTestParforsBase.compile_all   sV    33d33344 &&vs33 !!&#..f}rZ   c                     |                     dd          }|                     dd          }|                     dd          }|                     dd          }	|                     dd          }
d } || } || } || } |j        | } || } |j        | }|
at          j        j        ||fi | t          j        j        ||fi | |                     t          |          t          |                     nPt          |          t          |
          k    sJ t          ||||
          D ]\  }}}} |||fi |  |||fi | |	r| 	                    ||           |' |j         ||  }t          j        j        ||fi | dS dS )	a-  
        Checks python, njit and parfor impls produce the same result.

        Arguments:
            pyfunc - the python function to test
            cfunc - CompilerResult from njit of pyfunc
            cpfunc - CompilerResult from njit(parallel=True) of pyfunc
            args - arguments for the function being tested
        Keyword Arguments:
            scheduler_type - 'signed', 'unsigned' or None, default is None.
                           Supply in cases where the presence of a specific
                           scheduler is to be asserted.
            fastmath_pcres - a fastmath parallel compile result, if supplied
                             will be run to make sure the result is correct
            check_arg_equality - some functions need to check that a
                                 parameter is modified rather than a certain
                                 value returned.  If this keyword argument
                                 is supplied, it should be a list of
                                 comparison functions such that the i'th
                                 function in the list is used to compare the
                                 i'th parameter of the njit and parallel=True
                                 functions against the i'th parameter of the
                                 standard Python function, asserting if they
                                 differ.  The length of this list must be equal
                                 to the number of parameters to the function.
                                 The null comparator is available for use
                                 when you do not desire to test if some
                                 particular parameter is changed.
            Remaining kwargs are passed to np.testing.assert_almost_equal
        scheduler_typeNcheck_fastmathfastmath_pcrescheck_schedulingTcheck_arg_equalityc                     | st                      S g }| D ]O}t          |t          j                  r)|                    |                    d                     Ft          |t          j                  r(|                    |                                           t          |t          j                  r|                    |           ||                    |           t          |t                     r)|                    t          j	        |                     t          |t                    r|                    |d d                     Bt          d          t          |          S )Nkz%Unsupported argument type encountered)r   
isinstancenpndarrayappendcopynumbernumbersNumberdeepcopylist
ValueError)r   new_argsr   s      rX   	copy_argsz:TestParforsBase.check_parfors_vs_others.<locals>.copy_args   sP    wwH N Na,, NOOAFF3KK000029-- NOOAFFHH----7>22 	NOOA&&&&YOOA&&&&5)) NOODM!$4$455554(( NOOAaaaD))))$%LMMM??"rZ   )
popentry_pointr   testingassert_almost_equalassertEqualtypelenzipr   )rU   r   r   r   r   r   r   r   r   r   check_args_for_equalityr   py_argspy_expected	njit_argsnjit_outputparfor_argsparfor_outputpyargnjitarg	parforargargcompparfor_fastmath_outputs                          rX   check_parfors_vs_othersz'TestParforsBase.check_parfors_vs_others   s3   >  $4d;;$4d;;$4d;;!::&8$??"(**-A4"H"H	# 	# 	#, )T"fg& It$	'e'3  i&**K8"*J*;NNvNNNJ*=+PPPPPT+..]0C0CDDDDw<<3'>#?#?????69K1H7J 7J 4 42w	711&111	533F3333 	:!!&.999 %%?^%?DAQ%R"J*+A; 5 5-35 5 5 5 5 &%rZ   c                 N     | j         |g|R  \  }} | j        |||g|R i | dS )zChecks that pyfunc compiles for *args under parallel=True and njit
        and asserts that all version execute and produce the same resultNr   r   rU   r   r   r   r   r   s         rX   checkzTestParforsBase.check  sO     )(7$777v$$VUFLTLLLVLLLLLrZ   c           	           |            D ]`}|                      t          t          t          |                              5   | j        |g|R i | ddd           n# 1 swxY w Y   adS )zHRun self.check(impl, ...) on array data generated from arg_gen.
        N)subTestr   mapr   r   )rU   implarg_genr   r   s        rX   check_variantszTestParforsBase.check_variants#  s     GII 	2 	2Dd3vt#4#45566 2 2
41$111&1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2	2 	2s   A  A$	'A$	c           	      F    |            D ]}|                      t          t          t          |                              5  t	          t          t          |                    }|                     t          ||          d           ddd           n# 1 swxY w Y   dS )zXRun self.countParfors(impl, ...) on array types generated from
        arg_gen.
           N)r   r   r   r   r   assertGreaterEqualcountParfors)rU   r   r   r   r   argtyss         rX   count_parfors_variantsz&TestParforsBase.count_parfors_variants*  s     GII 	G 	GDd3vt#4#45566 G Gs640011''T6(B(BAFFFG G G G G G G G G G G G G G G	G 	Gs   ABB	B	c                     d}|!|dv r	|d|z   z  }nd}t          ||z            |                     ||j                                                   d S )Nz@do_scheduling)signedunsignedrL   z$Unknown scheduler_type specified: %s)r   assertInlibraryget_llvm_str)rU   cresr   scheduler_strmsgs        rX   r   z TestParforsBase.check_scheduling4  sj    (%!777~!55< ~!5666mT\%>%>%@%@AAAAArZ   c                 t    fd}t           |                      fdt          |          D             S )zFMake *ct* sample 1D arrays of length *n* using np.linspace().
        c               3      K   t          j        dd           V  t          j        dd           V  t          j        dd           V  d S Nr   r      r   linspacens   rX   genz)TestParforsBase.gen_linspace.<locals>.genC  s[      +aA&&&&&+aA&&&&&+aA&&&&&&&rZ   c                 .    g | ]}t                    S r~   )next)r   isrcs     rX   r   z0TestParforsBase.gen_linspace.<locals>.<listcomp>I  s    ---aS		---rZ   )r
   range)rU   r  ctr  r  s    `  @rX   gen_linspacezTestParforsBase.gen_linspace@  sP    	' 	' 	' 	' 	'
 CCEEll----599----rZ   c              #     K   |                      d|          V  d |                      d|          D             }|V  d |D             V  d |                      d|          D             }|V  d	 |D             V  d
S )z?Make 1D, 2D, 3D variants of the data in C and F orders
        
   )r	  c                 8    g | ]}|                     d           S )r      reshaper   s     rX   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>R  s4     > > > ))F## > > >rZ      )r  r	  c                 6    g | ]}t          j        |          S r~   r   asfortranarrayr   s     rX   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>V  #    444r ##444rZ   c                 8    g | ]}|                     d           S ))r   r     r  r   s     rX   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>Y  s:     B B B ))I&& B B BrZ      c                 6    g | ]}t          j        |          S r~   r  r   s     rX   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>]  r  rZ   N)r
  )rU   r	  arr2dsarr3dss       rX   gen_linspace_variantsz%TestParforsBase.gen_linspace_variantsK  s       r*****> >,,u,<<> > >44V444444B B,,yR,@@B B B44V44444444rZ   Nc                 X    fd|D             }||D ]}|t          |          v sJ |S )z. helper function to filter out modules by namec                 &    g | ]}|j         v |S r~   name)r   r   magicstrs     rX   r   z/TestParforsBase._filter_mod.<locals>.<listcomp>a  s%    555a(af"4"4"4"4"4rZ   )str)rU   modr"  checkstrfiltr   s     `   rX   _filter_modzTestParforsBase._filter_mod_  sP    55553555 * *3q66)))))rZ   c                 |    d |j         j        j        j        j        D             }|                     |||          S )z gets the gufunc LLVM Modulesc                     g | ]}|S r~   r~   r   s     rX   r   z7TestParforsBase._get_gufunc_modules.<locals>.<listcomp>i  s    JJJ!AJJJrZ   )r%  )r   _codegen_engine_ee_modulesr'  )rU   r   r"  r%  r-  s        rX   _get_gufunc_modulesz#TestParforsBase._get_gufunc_modulesg  s>    JJt|4<@IJJJ(XFFFrZ   c                     d}|                      ||          }t                      }|D ]} ||          ||j        <   |S )z$ helper for gufunc IR/asm generation__numba_parfor_gufunc)r.  dictr!  )rU   r   fnr"  gufunc_modsr   r$  s          rX   _get_gufunc_infoz TestParforsBase._get_gufunc_infol  sP     +..tX>>FF 	" 	"C"S''AchKKrZ   c                 8    |                      |t                    S )z
        Returns the IR of the gufuncs used as parfor kernels
        as a dict mapping the gufunc name to its IR.

        Arguments:
         cres - a CompileResult from `njit(parallel=True, ...)`
        )r4  r#  )rU   r   s     rX   _get_gufunc_irzTestParforsBase._get_gufunc_irv  s     $$T3///rZ   c                 \    |j         j        j        fd}|                     ||          S )z
        Returns the assembly of the gufuncs used as parfor kernels
        as a dict mapping the gufunc name to its assembly.

        Arguments:
         cres - a CompileResult from `njit(parallel=True, ...)`
        c                 H    t                              |                     S r\   )r#  emit_assembly)r$  tms    rX   emit_asmz1TestParforsBase._get_gufunc_asm.<locals>.emit_asm  s    r'',,---rZ   )r   r*  _tmr4  )rU   r   r;  r:  s      @rX   _get_gufunc_asmzTestParforsBase._get_gufunc_asm  sA     \"&	. 	. 	. 	. 	.$$T8444rZ   c                                            ||          }                     |          }d } fd}|                                D ]\  }} ||          }	 ||	           dS )a  
        Asserts that the fastmath flag has some effect in that suitable
        instructions are now labelled as `fast`. Whether LLVM can actually do
        anything to optimise better now the derestrictions are supplied is
        another matter!

        Arguments:
         pyfunc - a function that contains operations with parallel semantics
         sig - the type signature of pyfunc
        c                      | j                     }g }|D ].}t          j        d|          }||                    |           /|S )Nz\bfast\b)
splitlinesresearchr   )r   splitted	fast_instr   ms        rX   _get_fast_instructionsz?TestParforsBase.assert_fastmath.<locals>._get_fast_instructions  sT    $r}HI ( (Ik1--=$$Q'''rZ   c                 r    d}| D ]0}d}|D ]}|dz   }||v r|dz  }                     |dk               1d S )N)faddfsubfmulfdivfremfcmpcallr   z fastr   )
assertTrue)instrsopsinstcountopmatchrU   s         rX   _assert_fastz5TestParforsBase.assert_fastmath.<locals>._assert_fast  sj    JC + + # #BLE}}
	****+ +rZ   N)r   r6  items)
rU   r   r   r   _irrF  rV  r!  guirrR  s
   `         rX   assert_fastmathzTestParforsBase.assert_fastmath  s     --fc::!!$''	 	 		+ 	+ 	+ 	+ 	+ ))++ 	 	JD$))$//DL	 	rZ   r\   )ry   rP   rz   __doc__r{   r   r   r   r   r   r   r   r   r   r   r   r
  r  r'  r.  r4  r6  r=  rZ  __classcell__)r   s   @rX   r   r      s|         "5 5 5 5 5"8 8 8@ @ @E E E@ @ @	 	 	X5 X5 X5tM M M2 2 2G G G
B 
B 
B	. 	. 	.5 5 5(   G G G G
  0 0 05 5 5$ $ $ $ $ $ $rZ   r   c                    t          j        | |z            }d|z  |z  }|t          j        |          z  }||z   |z  |z   |z  }||z
  }	dd|z  z   }
dd|	z  z   }|t          j        | |z            z  }||z  }| |
z  |z
  }||z
  | z   }|S )N      ?      ?)r   logr   exp)sptpricestrikerate
volatilitytimevlogtermpowtermdend1d2NofXd1NofXd2futureValuec1rN  puts                   rX   blackscholes_implrq    s    fX&''GJ+G
rwu~~
%C7Ne#w
.#	5B	cB9r>!F9r>!F26D&5.111K	v	Bfr!D

x
'CJrZ   c                     t          |          D ]O}|t          j        ddt          j        |  t          j        ||          z            z   z  dz
  | z  |          z  }P|S Nr_  )r  r   dotra  )YXw
iterationsr  s        rX   lr_implry    sg    : N N	RVcS261"rva||*;#<#<<=CqH1MMMHrZ   c                 d   	 | j         \  }t          |          D ]}t          j         fdt          |          D                       t          j        fdt          |          D                       	t          j         	fdt                    D                       S )Nc                 L    g | ]fd t                    D              S )c                     g | ]=}t          t          j        d d f         |d d f         z
  dz                      >S Nr   )r   r   sum)r   jA	centroidsr  s     rX   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  s]     ; ; ;$% rvq111vi!!!n'<q&@AABB ; ; ;rZ   r  )r   r  r  r  	numCenters    @rX   r   z'example_kmeans_test.<locals>.<listcomp>  sc     N N N?@; ; ; ; ; ;).y)9)9; ; ; N N NrZ   c                 L    g | ] }|d d f                                          !S r\   argmin)r   r  dists     rX   r   z'example_kmeans_test.<locals>.<listcomp>  s1    @@@!4!!!9++--@@@rZ   c                 L    g | ]fd t                    D              S )c                     g | ];}t          j        k    |f                   t          j        k              z  <S r~   r   r~  )r   r  r  r  labelss     rX   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  sR     4 4 4%&  "va	1o66rvfai7H7HH 4 4 4rZ   r  )r   r  r  Dr  s    @rX   r   z'example_kmeans_test.<locals>.<listcomp>  sa     O O O894 4 4 4 4 4*/((4 4 4 O O OrZ   )shaper  r   array)
r  r  numIterinit_centroidsNlr  r  r  r  s
   ``    @@@@rX   example_kmeans_testr    s	   I7DAq7^^ P Px N N N N N NDI!HHN N N O O@@@@uQxx@@@AAH O O O O O O=B9=M=MO O O P P		 rZ   c                    t          j                    }t          j        |d          }t	          j        |           }|rt          j        |          }nt          j        d          }t          ||||          }t          j	        ||          5  |
                                 |
                                 t          j        |j        j        |d          }|                                 t           j                            d|j                   t'          j        |j        j        |j        j        |j        j        |j        j        d           \  |j        _        |j        _        |j        _        }	t7          j        |j        j        |j        j        |j        j        dd |j        j        |j        j        t:          j                   t>          j         j!        "                                }
t>          j         j!        #                    |j        j        |j        j        |j        j        |j        j        |j        j        ||
j$                  }|                                 t           j                            d|j                   t	          j%                    }t>          j         j!        &                    |j        j        |j        j        |j        j        |j        j        |j        j        |j        j        |||j        j'        |
	
  
        }|                                 t>          j         j!        (                    |j        j        |j        j        |j        j        |j        j        |j        j        |j        j        |||j        j'        |
	
  
        }|                                 t>          j         j!        )                    |j        j        |j        j        |j        j        |j        j        |j        j        |j        j        |||j        j'        |
	
  
        }|                                 tU          |j+                  |_,        d d d            n# 1 swxY w Y   ||fS )
Nr   T)typedzbefore-inferencer~   )func_irtypemap	calltypesliftedlifted_fromr   return_typehtml_output)swappedzafter-inference)diagnostics)-r   Contextr   
CPUContextr   run_frontendr   TestPipeliner$   nested_contextrefreshr   InlineClosureCallPassstater  runr   rewrite_registryapplyr   type_inference_stage	typingctx	targetctxr   r  r  r  r%   TypeAnnotationr   HTMLr   parforsparforParforDiagnosticsPreParforPassreplaced_fnsr0   
ParforPassmetadataParforFusionPassParforPreLoweringPassr(   blocks_definitions)	test_funcr   kwsr  r  test_iroptionstpinline_passrL   r  preparfor_passr   parfor_passs                 rX   get_optimized_numba_irr    s     Iy%00I#I..G
 ,%c**%d++	iD'	:	:B		"9i	8	8 3A 3A(>rx?O?FEIK K K 	!''(:BHEEE 	)"(*<H 0"(-	G 	G 	F"(.0BA 	'H$H$h(,	% 	% 	% 	% m*<<>>-;;Hbh.0BH 2G, < . . 	!''(928DDD  m*55Hbh.0BH "("4bh6HUBH-; 6 H H 	m*;;Hbh.0BH "("4bh6HUBH-; < H H 	m*@@Hbh.0BH "("4bh6HUBH-; A H H 	0@@g3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3A 3Aj B;s   O QQ"Qc                     t          | |fi |\  }}d}|j                                        D ]H\  }}t          |j                  D ].\  }}	t          |	t          j        j        j	                  r|dz  }/I|S Nr   r   )
r  r  rW  	enumeratebodyr   r   r  r  Parfor)
r  r   r  r  r  	ret_countlabelblockr  rR  s
             rX   r   r     s    (D@@C@@KGRI,,..  u ,, 	 	GAt$ 4 ;<< Q		 rZ   c                 b    t          | |fi |\  }}t          |j        |j        j                  S r\   )r  _count_arrays_innerr  r  r  r  r   r  r  r  s        rX   countArraysr  &  s4    (D@@C@@KGRw~rx/?@@@rZ   c                 "   t          | |fi |\  }}|j        }d}|                                D ]_\  }}t          |j                  D ]E\  }	}
t          |
t          j        j        j	                  r|t          |
j        j                  z  }F`|S Nr   )r  r  rW  r  r  r   r   r  r  r  r   
init_block)r  r   r  r  r  r  r  r  r  r  rR  s              rX   get_init_block_sizer  *  s    (D@@C@@KGR^FI 7 7u ,, 	7 	7GAt$ 4 ;<< 7S!5666		7 rZ   c                 ,   d}t                      }|                                 D ]\  }}t          |j                  D ]\  }}t	          |t
          j        j        j                  r6|j	        
                                }|j        |d<   |t          ||          z  }t	          |t          j                  rIt	          ||j        j                 t"          j                  r|                    |j        j                   Ì|t)          |          z  }|S r  )setrW  r  r  r   r   r  r  r  	loop_bodyr   r  r  r   Assigntargetr!  r   ArrayCompatibleaddr   )	r  r  r  arr_setr  r  r  rR  parfor_blockss	            rX   r  r  7  s   IeeG 	. 	.u ,, 	. 	.GAt$ 4 ;<< I $ 3 3 5 5#'?a 0HHH	4++ ."74;+;#<$)$9; ;. DK,---	. WIrZ   c                     t          | |fi |\  }}d}|j                                        D ]}|t          ||          z  }|S r  )r  r  values_count_array_allocs_inner)r  r   r  r  r  r  r  s          rX   countArrayAllocsr  I  s\    (D@@C@@KGRI&&(( ? ?.w>>>		rZ   c                    d}|j         D ]}t          |t          j        j        j                  rG|t          | |j                  z  }|j        	                                D ]}|t          | |          z  }t          |t          j                  rrt          |j        t          j                  rS|j        j        dk    rCt          t           | |j                  dk    st          t           | |j                  dk    r|dz  }|S )Nr   rN  )emptynumpy)r-   znumba.np.unsafe.ndarrayr   )r  r   r   r  r  r  r  r  r  r  r   r  valueExprrT  r'   r&   )r  r  r  rR  r   s        rX   r  r  R  s   I
  dEM0788 	C27DOLLLI^**,, C C6wBBB		tRY'' 	Jtz27,K,K 	JMV++='4:>>BTTT<<DE ENIrZ   c                 d    t          | |fi |\  }}t          ||j        |j        j                  S r\   )r  &_count_non_parfor_array_accesses_innerr  r  r  r  s        rX   countNonParforArrayAccessesr  c  s@    (D@@C@@KGR1'7>24(2BD D DrZ   c           	         d}|t                      }|                                D ]\  }}|j        D ]}t          |t          j        j        j                  rX|                    |j	        j
                   |j                                        }|j        |d<   |t          | |||          z  }t          |          rSt          ||j        j        j
                 t"          j                  r$t'          | t)          |          |          s|dz  }t+          |          rOt          ||j        j
                 t"          j                  r%t'          | t)          |          |          s|dz  }?t          |t.          j                  rLt          |j        t.          j                  r-|j        j
        |v r|                    |j        j
                   |S r  )r  rW  r  r   r   r  r  r  r  	index_varr!  r  r   r  r  r*   r  r   r  _uses_indicesr,   r+   r  r   r  Var)	f_irr  r  parfor_indicesr  r  r  stmtr  s	            rX   r  r  h  s   I 5 5uJ 	5 	5D$ 4 ;<< 5""4>#6777 $ 3 3 5 5#'?a C-.B B B		 T"" 5z'$*:J:O2P-(/ (/ 57D6t<<n8N 8N5 Q		 T"" 	5z'$+:J2K)(+ (+ 	53@2488.4J 4J	5 Q		 T29-- 5TZ005*/^33""4;#34441	54 rZ   c                     |j         |v rdS t          t          | |          }t          |t          j                  r?|j        dk    r4t          d |j        D                       }t          ||z            dk    S dS )NTbuild_tuplec              3   $   K   | ]}|j         V  d S r\   r   )r   vs     rX   	<genexpr>z _uses_indices.<locals>.<genexpr>  s$      55!qv555555rZ   r   F)
r!  r'   r)   r   r   r  rT  r  rW  r   )r  index	index_setind_defvarnamess        rX   r  r    s    zYtND%00G'27## .
m(C(C55w}555558i'((A--5rZ   c                       e Zd Zd ZdS )r  c                     t          j                    | _        || j        _        || j        _        || j        _        || j        _        d | j        _        d | j        _        d | j        _	        i | j        _
        d S r\   )r   	StateDictr  r  r  r   r  r  r  r  r  )rU   r  r  r   r  s        rX   r   zTestPipeline.__init__  sg    '))
(
(

$
!
!%
#
 
rZ   N)ry   rP   rz   r   r~   rZ   rX   r  r    s#        	! 	! 	! 	! 	!rZ   r  c                   $   e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zed             Zed             Zed             Zed             Zd Zd Zd Zed             Zed             Zed             Z d Z!dS )TestParforBasiczZSmoke tests for the parfors transforms. These tests check the most basic
    functionalityc                     t          j        | g|R   t          j        t          j        d          d          }t          j        d          t          j        d          ||j        g| _        d S )N      (@r  r        @      @)r   r   r   r  arangeTsimple_args)rU   r   rE  s      rX   r   zTestParforBasic.__init__  s]     -----Jry~~v..IbMM29R==!QSArZ   c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                  *    t          j        d          S )Nr~   r   onesr~   rZ   rX   	test_implz0TestParforBasic.test_simple01.<locals>.test_impl  s    72;;rZ   '@do_scheduling' not foundassertRaisesAssertionErrorr   r   r#  	exceptionrU   r	  raisess      rX   test_simple01zTestParforBasic.test_simple01  s    	 	 	~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLL   A  AAc                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r  r~   rZ   rX   r	  z0TestParforBasic.test_simple02.<locals>.test_impl  s    74== rZ   r   rU   r	  s     rX   test_simple02zTestParforBasic.test_simple02  s)    	! 	! 	!

9rZ   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S Nr   r   r  r~   rZ   rX   r	  z0TestParforBasic.test_simple03.<locals>.test_impl      76??"rZ   r  r  s     rX   test_simple03zTestParforBasic.test_simple03  )    	# 	# 	#

9rZ   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S Nr   r  r~   rZ   rX   r	  z0TestParforBasic.test_simple04.<locals>.test_impl  s    71::rZ   r  r  s     rX   test_simple04zTestParforBasic.test_simple04  s)    	 	 	

9rZ   c                 6    d }|                      |           d S )Nc                  B    t          j        dt           j                  S )Nr  dtyper   r  
complex128r~   rZ   rX   r	  z0TestParforBasic.test_simple07.<locals>.test_impl  s    767777rZ   r  r  s     rX   test_simple07zTestParforBasic.test_simple07  s)    	8 	8 	8

9rZ   c                 6    d }|                      |           d S )Nc                  T    t          j        d          t          j        d          z   S r  r  r~   rZ   rX   r	  z0TestParforBasic.test_simple08.<locals>.test_impl  s    76??RWV__44rZ   r  r  s     rX   test_simple08zTestParforBasic.test_simple08  s)    	5 	5 	5

9rZ   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r   r  r~   rZ   rX   r	  z0TestParforBasic.test_simple09.<locals>.test_impl  r  rZ   r  r  s     rX   test_simple09zTestParforBasic.test_simple09  r  rZ   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r   r  r~   rZ   rX   r	  z0TestParforBasic.test_simple10.<locals>.test_impl  r  rZ   r  r  s     rX   test_simple10zTestParforBasic.test_simple10  r  rZ   c                 6    d }|                      |           d S )Nc                  0    t          j        d          dz   S Nr  r  r_  r  r~   rZ   rX   r	  z0TestParforBasic.test_simple11.<locals>.test_impl  s    78$$r))rZ   r  r  s     rX   test_simple11zTestParforBasic.test_simple11  s)    	* 	* 	*

9rZ   c                 6    d }|                      |           d S )Nc                  T    t          j        d          t          j        d          z   S r8  r(  r~   rZ   rX   r	  z0TestParforBasic.test_simple12.<locals>.test_impl  s!    78$$r}R'8'888rZ   r  r  s     rX   test_simple12zTestParforBasic.test_simple12  s)    	9 	9 	9

9rZ   c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                  *    t          j        d          S rs  )r   r)  r~   rZ   rX   r	  z0TestParforBasic.test_simple13.<locals>.test_impl  s    =$$$rZ   r
  r  r  s      rX   test_simple13zTestParforBasic.test_simple13  s    	% 	% 	%~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLLr  c                 6    d }|                      |           d S )Nc                  <    t          j        d          dd d         S )Nr9  r      r  r~   rZ   rX   r	  z0TestParforBasic.test_simple14.<locals>.test_impl  s    78$$QUU++rZ   r  r  s     rX   test_simple14zTestParforBasic.test_simple14  s)    	, 	, 	,

9rZ   c                 2    d } | j         |g| j        R   d S )Nc                     | | z   S r\   r~   v1v2m1m2s       rX   r	  z0TestParforBasic.test_simple15.<locals>.test_impl      7NrZ   r   r  r  s     rX   test_simple15zTestParforBasic.test_simple15  4    	 	 	
90t/000000rZ   c                 2    d } | j         |g| j        R   d S )Nc                     ||z   S r\   r~   rG  s       rX   r	  z0TestParforBasic.test_simple16.<locals>.test_impl  rL  rZ   rM  r  s     rX   test_simple16zTestParforBasic.test_simple16  rO  rZ   c                 2    d } | j         |g| j        R   d S )Nc                     || z   S r\   r~   rG  s       rX   r	  z0TestParforBasic.test_simple17.<locals>.test_impl  rL  rZ   rM  r  s     rX   test_simple17zTestParforBasic.test_simple17  rO  rZ   c                 2    d } | j         |g| j        R   d S )Nc                 \    |j         t          j                            |          d         z   S r"  )r  r   linalgsvdrG  s       rX   r	  z0TestParforBasic.test_simple18.<locals>.test_impl  s"    4")--++A...rZ   rM  r  s     rX   test_simple18zTestParforBasic.test_simple18  s4    	/ 	/ 	/
90t/000000rZ   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||          S r\   r   rt  rG  s       rX   r	  z0TestParforBasic.test_simple19.<locals>.test_impl      6"b>>!rZ   rM  r  s     rX   test_simple19zTestParforBasic.test_simple19  4    	" 	" 	"
90t/000000rZ   c                     d }|                      t                    5 } | j        |g| j        R   d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nc                 ,    t          j        ||          S r\   r]  rG  s       rX   r	  z0TestParforBasic.test_simple20.<locals>.test_impl  r^  rZ   r
  )r  r  r   r  r   r#  r  r  s      rX   test_simple20zTestParforBasic.test_simple20	  s    	" 	" 	" ~.. 	5&DJy44#34444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	54c&:J6K6KLLLLLs   >AAc                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        | |           S r\   r]  rG  s       rX   r	  z0TestParforBasic.test_simple21.<locals>.test_impl  r^  rZ   rM  r  s     rX   test_simple21zTestParforBasic.test_simple21  r`  rZ   c                 2    d } | j         |g| j        R   d S )Nc                 0    t          j        | | z             S r\   r  rG  s       rX   r	  z0TestParforBasic.test_simple22.<locals>.test_impl  s    6"r'??"rZ   rM  r  s     rX   test_simple22zTestParforBasic.test_simple22  s4    	# 	# 	#
90t/000000rZ   c                 2    d } | j         |g| j        R   d S )Nc                 d    d| z  }d| z  }dt          j        |dz  |dz  z   dk               z  dz  S )Nr   r  r   r  r  )rH  rI  rJ  rK  r   ys         rX   r	  z0TestParforBasic.test_simple23.<locals>.test_impl  s>    BABArvadQTkAo...33rZ   rM  r  s     rX   test_simple23zTestParforBasic.test_simple23  s6    	4 	4 	4 	
90t/000000rZ   c                 6    d }|                      |           d S )Nc                      d} t          j        | | f          }t          j        |           }t          j        |d d |f                   S )NrC  )r   r  r  r~  )r  r  r   s      rX   r	  z0TestParforBasic.test_simple24.<locals>.test_impl%  s?    AAA	!A6!AAAqD'??"rZ   r  r  s     rX   test_simple24zTestParforBasic.test_simple24$  s+    	# 	# 	#
 	

9rZ   c                 2    d } | j         |g| j        R   dS )zAsame as corresponding test_simple_<n> case but using operator.addc                 ,    t          j        | |           S r\   operatorr  rG  s       rX   r	  z:TestParforBasic.test_simple_operator_15.<locals>.test_impl/      <B'''rZ   NrM  r  s     rX   test_simple_operator_15z'TestParforBasic.test_simple_operator_15,  s6    	( 	( 	( 	
90t/000000rZ   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||          S r\   rs  rG  s       rX   r	  z:TestParforBasic.test_simple_operator_16.<locals>.test_impl6  ru  rZ   rM  r  s     rX   test_simple_operator_16z'TestParforBasic.test_simple_operator_164  6    	( 	( 	( 	
90t/000000rZ   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||           S r\   rs  rG  s       rX   r	  z:TestParforBasic.test_simple_operator_17.<locals>.test_impl=  ru  rZ   rM  r  s     rX   test_simple_operator_17z'TestParforBasic.test_simple_operator_17;  rz  rZ   c                 l    d }d }t          j        d          }|                     |||g           d S )Nc                     | dz  } d| d d <   d S )Nr   r  r~   r   s    rX   r	  z5TestParforBasic.test_inplace_alias.<locals>.test_implD  s    FAAaaaDDDrZ   c                 F    t           j                            | |           d S r\   r   r   assert_equalr   s     rX   comparerz4TestParforBasic.test_inplace_alias.<locals>.comparerH       J##Aq)))))rZ   r   r   r   r  r   )rU   r	  r  r   s       rX   test_inplace_aliasz"TestParforBasic.test_inplace_aliasB  sO    	 	 		* 	* 	* GAJJ

9aXJ
?????rZ   N)"ry   rP   rz   r[  r   r  r  r  r#  r*  r-  r1  r5  r:  r=  r@  rD  rN  rR  rU  r?   rZ  r>   r_  rc  rf  ri  rm  rp  r@   rv  ry  r}  r  r~   rZ   rX   r  r    s        B B BM M M  
  
  
  
  
  
  
  
  
M M M  
1 1 1
1 1 1
1 1 1
 1 1 \1
 1 1 Z1
 M M ZM 1 1 Z1
1 1 1
1 1 1   1 1 ]1 1 1 ]1 1 1 ]1
@ 
@ 
@ 
@ 
@rZ   r  c                   :    e Zd ZdZd Zd Zed             Zd ZdS )TestParforNumericalMiscz+ Miscellaneous 'classical' numerical tests c                     d }|                      |dd           |                     t          |t          j        f          d           |                     t          |t          j        f          d           d S )Nc                     dt           j                            |           z  dz
  }dt           j                            |           z  dz
  }dt          j        |dz  |dz  z   dk               z  | z  S )Nr   r   r  )r   randomranfr~  )r  r   rl  s      rX   r	  z2TestParforNumericalMisc.test_pi.<locals>.test_implT  sf    BINN1%%%)ABINN1%%%)ArvadQTkAo...22rZ   i r   decimalr   )r   r   r   r   int64r  intpr  s     rX   test_pizTestParforNumericalMisc.test_piS  sy    	3 	3 	3
 	

9fa
000i%+AA1EEEY>>BBBBBrZ   c                     t           j        d d          fdz  }|                     t          t          |          d           d S Nr   r   )r   float64r   r   rq  rU   r   s     rX   test_blackscholesz)TestParforNumericalMisc.test_blackscholes]  sA    aaa #a'&7>>BBBBBrZ   c                 >   t           j        d d          t           j        d d d d f         t           j        d d          t           j        f}|                     t	          t
          |          d           |                     t          t
          |          d           d S Nr   r   )r   r  r  r   r   ry  r  r  s     rX   test_logistic_regressionz0TestParforNumericalMisc.test_logistic_regressionb  s    aaa %-!!!"4emAAA6Fgt44a888)'488!<<<<<rZ   c                    t           j                            d           d}d}d}t           j                            ||f          }t           j                            ||f          }|                     t
          ||d|d           t          j        t          j        dd          t          j	        t          j	        t          j        t          j        dd          f}| 
                    t          t
          |          d           d S )	Nr      r  r  r   r  r   C)r   r  seedr  r   r  r   Arrayr  r  r   r  )rU   r  r  centersr  r  arg_typss          rX   test_kmeansz#TestParforNumericalMisc.test_kmeansi  s    
	qINNAq6""!55

&7A~LM 	 	O 	O 	O Kq#66
EJKq#668'(;XFF	K 	K 	K 	K 	KrZ   N)	ry   rP   rz   r[  r  r  r>   r  r  r~   rZ   rX   r  r  O  sm        55C C CC C C
 = = Z=K K K K KrZ   r  c                       e Zd ZdZed             Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestParforNumPyz'Tests NumPy functionality under parforsc                     d }t          j        ddd                              dd          }t          j        ddd          }|                     |||           d S )Nc                 ,    t          j        | |          S r\   r]  r   r  s     rX   r	  z-TestParforNumPy.test_mvdot.<locals>.test_impl      6!Q<<rZ   r   r   rC  r   r  )r   r   r  r   )rU   r	  r  r  s       rX   
test_mvdotzTestParforNumPy.test_mvdot~  se    	  	  	  K1b!!))!R00K1b!!

9a#####rZ   c                 \   t           j        t           j        t           j        t           j        fD ]{fd}|                     |d           |                     t          |t          j	        f          d           |                     t          |t          j        f          d           |d S )Nc                 t    t          j        |           } |          }|                                }||z   S r\   r   r  r~  )r  r  r  BrT  s       rX   r	  zBTestParforNumPy.test_fuse_argmin_argmax_max_min.<locals>.test_impl  s3    GAJJBqEEEEGG1urZ      r   r   )r   r  argmaxminmaxr   r   r   r   r  r  r  )rU   r	  rT  s     @rX   test_fuse_argmin_argmax_max_minz/TestParforNumPy.test_fuse_argmin_argmax_max_min  s    9bi8 	G 	GB    
 JJy#&&&\)ek_EEqIII[UZMBBAFFFF	G 	GrZ   c                 j    d }|                      t          |t          j        f          d           d S )Nc                 0    t          |           }|d         S r  r   r  r  s     rX   r	  zDTestParforNumPy.test_np_random_func_direct_import.<locals>.test_impl  s    aAQ4KrZ   r   r   r   r   r  r  s     rX   !test_np_random_func_direct_importz1TestParforNumPy.test_np_random_func_direct_import  s=    	 	 	 	i%+AA1EEEEErZ   c                     d }d }d }dddt          dd          t          dd          fD ]G}|                     ||           |                     |d	|           |                     |d	|d	           Hd S )
Nc                 *    t          j        |           S r\   r   r  r  s    rX   
test_impl1z/TestParforNumPy.test_arange.<locals>.test_impl1      9Q<<rZ   c                 *    t          j        |          S r\   r  )sr  s     rX   
test_impl2z/TestParforNumPy.test_arange.<locals>.test_impl2  r  rZ   c                 .    t          j        | ||          S r\   r  )r  r  ts      rX   
test_impl3z/TestParforNumPy.test_arange.<locals>.test_impl3  s    9Q1%%%rZ               >@r  r   r   complexr   )rU   r  r  r  args        rX   test_arangezTestParforNumPy.test_arange  s    	  	  	 	  	  	 	& 	& 	& T71Q<<1> 	. 	.CJJz3'''JJz1c***JJz1c1----	. 	.rZ   c                     d }d }dddt          dd          t          dd          fD ]1}|                     |d|           |                     |d|d	           2d S )
Nc                 ,    t          j        | |          S r\   r   )startstops     rX   r  z1TestParforNumPy.test_linspace.<locals>.test_impl1  s    ;ud+++rZ   c                 .    t          j        | ||          S r\   r   )r  r  nums      rX   r  z1TestParforNumPy.test_linspace.<locals>.test_impl2  s    ;udC000rZ   r  r  r  r  r   r      r  )rU   r  r  r  s       rX   test_linspacezTestParforNumPy.test_linspace  s    	, 	, 	,	1 	1 	1 T71Q<<1> 	/ 	/CJJz1c***JJz1c2....	/ 	/rZ   c           
      \    d }d}t           j                            |          }t           j                            d|df          }                     ||                                ||                                t          |t          j        t          j	        dd          f          d                                t          |t          j        t          j	        dd          f          d            fd	} 
                    ||                                ||           d S )
Nc                 *    |                                  S r\   meanr  s    rX   r	  z,TestParforNumPy.test_mean.<locals>.test_impl  s    6688OrZ   d   r  r  sizer   r  r   c                  .                          d          S r"  r  r^   s   rX   <lambda>z+TestParforNumPy.test_mean.<locals>.<lambda>      455a88 rZ   r   r  r  randintr   r   r   r   r  r  r   r   )rU   r	  r  r  r  data_gens   `     rX   	test_meanzTestParforNumPy.test_mean  s   	 	 	INN1Ib1v..

9a   

9a   i%+emQPS2T2T1WXXZ[\\\i%+emQPS2T2T1WXXZ[\\\ 9888Ix000##Ix88888rZ   c           
          d }d}t           j                            |          }t           j                            d|df          }|d|z  z   }                     ||                                ||                                ||                                t          |t          j        t          j	        dd          f          d	                                t          |t          j        t          j	        d	d          f          d	            fd
} 
                    ||                                ||           d S )Nc                 *    |                                  S r\   )varr  s    rX   r	  z+TestParforNumPy.test_var.<locals>.test_impl      5577NrZ   r  r  r  r                ?r   r  r   c                  .                          d          S r"  r  r^   s   rX   r  z*TestParforNumPy.test_var.<locals>.<lambda>  r  rZ   r  )rU   r	  r  r  r  r  r  s   `      rX   test_varzTestParforNumPy.test_var  s=   	 	 	INN1Ib1v..QJ

9a   

9a   

9a   i%+emQPS2T2T1WXXZ[\\\i%+emQPS2T2T1WXXZ[\\\ 9888Ix000##Ix88888rZ   c                 ^    d }d}t           j                            |          }t           j                            d|df          }|d|z  z   }                     ||                                ||                                ||           t          j        t
          j        dd          f}                     t          ||          d	                                t          ||          d	            fd
} 
                    ||                                ||           d S )Nc                 *    |                                  S r\   )stdr  s    rX   r	  z+TestParforNumPy.test_std.<locals>.test_impl  r  rZ   r  r  r  r  r  r   r  r   c                  .                          d          S r"  r  r^   s   rX   r  z*TestParforNumPy.test_std.<locals>.<lambda>  r  rZ   )r   r  r  r  r   r   r  r  r   r   r   r   )rU   r	  r  r  r  r  argtyr  s   `       rX   test_stdzTestParforNumPy.test_std  s+   	 	 	INN1Ib1v..QJ

9a   

9a   

9a   U]As335i77;;;i77;;; 9888Ix000##Ix88888rZ   c                 j    d }|                      t          |t          j        f          d           dS )z
        Test function with only a random call to make sure a random function
        like ranf is actually translated to a parfor.
        c                 H    t           j                            | | f          }|S r\   )r   r  r  r  s     rX   r	  z5TestParforNumPy.test_random_parfor.<locals>.test_impl  s    	1v&&AHrZ   r   Nr  r  s     rX   test_random_parforz"TestParforNumPy.test_random_parfor  s=    
	 	 	 	i%+AA1EEEEErZ   c                 D   d }d}|                      |t          j        |          f          }|                    |          } ||          }t          j                            ||d           |                     t          |t          j
        f          d           d S )Nc                    t           j                            | | f          }t           j                            | |           }t           j                            dd| | f          }t           j                            d| | f          }t           j                            dd| | f          }t           j                            ddd| | f          }t          j        ||z   |z   |z   |z   |z             S Nr          r_  r   r  )highr  r   )	r   r  standard_normalr   normal	chisquarer  
triangularr~  r  r  r  r  r  EFs          rX   r	  z/TestParforNumPy.test_randoms.<locals>.test_impl  s    	))1v)66A	1%%A	  cAq622A	##C!Q00A	!!!!1a&!99A	$$Q1q!f55A6!A#a%'!)A+&&&rZ   r  g?)rtolr   )r   r   r   r   r   r   assert_allcloser   r   r   r  rU   r	  r  r   r   	py_outputs         rX   test_randomszTestParforNumPy.test_randoms  s    	' 	' 	' &&y5<??2DEE**1--IaLL	

""=)$"GGGi%+AA1EEEEErZ   c                 ,   d }d}|                      |t          j        |          f          }|                    |          } ||          }|                     ||           |                     t          |t          j        f          d           d S )Nc                    t           j                            | | f          }t           j                            | |           }t           j                            dd| | f          }t           j                            d| | f          }t           j                            dd| | f          }t           j                            ddd| | f          }dS r  )r   r  r  r   r  r  r  r  r  s          rX   r	  z4TestParforNumPy.test_dead_randoms.<locals>.test_impl  s    	))1v)66A	1%%A	  cAq622A	##C!Q00A	!!!!1a&!99A	$$Q1q!f55A1rZ   r  r   )r   r   r   r   r   r   r   r  r  s         rX   test_dead_randomsz!TestParforNumPy.test_dead_randoms  s    	 	 	 &&y5<??2DEE**1--IaLL		222i%+AA1EEEEErZ   c                      d }d }d}t           j                            |          }t           j                            d|                              t           j                  }t           j                            ||f          }t          j        t           j        t           j        g          }                     ||                                ||                                ||                                ||                                ||                                ||                                ||                                ||           d}||fD ]}	 	                    |	t          j        d d          f          }
                     t                    5 }|
                    t          j        g t           j                             d d d            n# 1 swxY w Y                        |t!          |j                              fd}                     ||                                ||                                ||                                ||           d S )	Nc                 *    |                                  S r\   r  r  s    rX   r  z,TestParforNumPy.test_min.<locals>.test_impl1  r  rZ   c                 *    t          j        |           S r\   )r   r  r  s    rX   r  z,TestParforNumPy.test_min.<locals>.test_impl2      6!99rZ      r  r  zDzero-size array to reduction operation minimum which has no identityr&  c                  .                          d          S r"  r  r^   s   rX   r  z*TestParforNumPy.test_min.<locals>.<lambda>6  r  rZ   r   r  r  r  astypeint32r  infr   r   r   r  r  r   r   r   r#  r  r   r   rU   r  r  r  r  r  r  r  r   r   pcfuncer  s   `            rX   test_minzTestParforNumPy.test_min  s   	 	 		 	 	 INN1Ibq))00::INNAq6""Hbfbf%&&

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!/, 	1 	1D**4%+aaa.1BCCF"":.. A!""28Bbh#?#?#?@@@A A A A A A A A A A A A A A AMM#s1;//0000 9888J111##J999J111##J99999s   -4G--G1	4G1	c                     d }d }d}t           j                            |          }t           j                            d|                              t           j                  }t           j                            ||f          }t          j        t           j         t           j         g          }                     ||                                ||                                ||                                ||                                ||                                ||                                ||                                ||           d}||fD ]}	 	                    |	t          j        d d          f          }
                     t                    5 }|
                    t          j        g t           j                             d d d            n# 1 swxY w Y                        |t!          |j                              fd}                     ||                                ||                                ||                                ||           d S )	Nc                 *    |                                  S r\   )r  r  s    rX   r  z,TestParforNumPy.test_max.<locals>.test_impl1=  r  rZ   c                 *    t          j        |           S r\   )r   r  r  s    rX   r  z,TestParforNumPy.test_max.<locals>.test_impl2@  r  rZ   r  r  r  zDzero-size array to reduction operation maximum which has no identityr&  c                  .                          d          S r"  r  r^   s   rX   r  z*TestParforNumPy.test_max.<locals>.<lambda>[  r  rZ   r  r  s   `            rX   test_maxzTestParforNumPy.test_max<  s   	 	 		 	 	 INN1Ibq))00::INNAq6""Hrvgw'((

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!/, 	1 	1D**4%+aaa.1BCCF"":.. A!""28Bbh#?#?#?@@@A A A A A A A A A A A A A A AMM#s1;//0000 9888J111##J999J111##J99999s   /4G//G3	6G3	c                     d }d }d}t          j        g d          }t           j                            d|                              t           j                  }t           j                            ||f          }t          j        ddt           j        d	d
g          }                     ||                                ||                                ||                                ||                                ||                                ||                                ||                                ||           d}||fD ]}	 	                    |	t          j        d d          f          }
                     t                    5 }|
                    t          j        g t           j                             d d d            n# 1 swxY w Y                        |t!          |j                              fd}                     ||                                ||                                ||                                ||           d S )Nc                 *    |                                  S r\   )r  r  s    rX   r  z/TestParforNumPy.test_argmax.<locals>.test_impl1b      88::rZ   c                 *    t          j        |           S r\   )r   r  r  s    rX   r  z/TestParforNumPy.test_argmax.<locals>.test_impl2e  r  rZ   r  )r_  r  r          @r   r  r  r_  r  r  r   z*attempt to get argmax of an empty sequencer&  c                  .                          d          S r"  r  r^   s   rX   r  z-TestParforNumPy.test_argmax.<locals>.<lambda>  r  rZ   r   r  r  r  r  r  r  nanr   r   r   r  r  r   r   r   r#  r  r   r   r  s   `            rX   test_argmaxzTestParforNumPy.test_argmaxa     	 	 		  	  	  H)))**Ibq))00::INNAq6""Hb"bfb"-..

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!!

:q!!! ;, 	1 	1D**4%+aaa.1BCCF"":.. A!""28Bbh#?#?#?@@@A A A A A A A A A A A A A A AMM#s1;//0000 9888J111##J999J111##J99999   4GG!	$G!	c                     d }d }d}t          j        g d          }t           j                            d|                              t           j                  }t           j                            ||f          }t          j        ddt           j        dd	g          }                     ||                                ||                                ||                                ||                                ||                                ||                                ||                                ||           d
}||fD ]}	 	                    |	t          j        d d          f          }
                     t                    5 }|
                    t          j        g t           j                             d d d            n# 1 swxY w Y                        |t!          |j                              fd}                     ||                                ||                                ||                                ||           d S )Nc                 *    |                                  S r\   r  r  s    rX   r  z/TestParforNumPy.test_argmin.<locals>.test_impl1  r  rZ   c                 *    t          j        |           S r\   )r   r  r  s    rX   r  z/TestParforNumPy.test_argmin.<locals>.test_impl2  r  rZ   r  )r_  r  r  r  r   r  r  r_  r  r   z*attempt to get argmin of an empty sequencer&  c                  .                          d          S r"  r  r^   s   rX   r  z-TestParforNumPy.test_argmin.<locals>.<lambda>  r  rZ   r!  r  s   `            rX   test_argminzTestParforNumPy.test_argmin  r$  r%  c                     d }t          j        d          }|                     ||           t          j        t          j        dd          f}|                     t          ||          d           d S )Nc                 0    |                      d           | S N      @fillr   s    rX   r	  z4TestParforNumPy.test_ndarray_fill.<locals>.test_impl      FF3KKKHrZ   r  r   r  r   zerosr   r   r  r  r   r   rU   r	  r   r  s       rX   test_ndarray_fillz!TestParforNumPy.test_ndarray_fill  sr    	 	 	 HRLL

9a   U]As335i77;;;;;rZ   c                     d }t          j        d          }|                     ||           t          j        t          j        dd          f}|                     t          ||          d           d S )Nc                 0    |                      d           | S r-  r/  r1  s    rX   r	  z6TestParforNumPy.test_ndarray_fill2d.<locals>.test_impl  r2  rZ   r   r   r   r  r   r3  r5  s       rX   test_ndarray_fill2dz#TestParforNumPy.test_ndarray_fill2d  sr    	 	 	 HUOO

9a   U]As335i77;;;;;rZ   c                 j    d }t          j        g d          }d}|                     |||           d S )Nc                     t          j        ||dft           j                  }| d|         }|j        } | dz  }|                    dd          }||z  }||d d d d df<   |S Nr   r&  r   rK   r   r4  r  r  r  r   r   result_matrixsub_azresult_datas         rX   r	  z<TestParforNumPy.test_reshape_with_neg_one.<locals>.test_impl  su    HaAYbjAAAMacFE
AAAb!$$A!)K#.M!!!AAAa%   rZ   r_  r  r   r        @      @r.  g       @g      "@      $@g      &@r  r  r   r  r   rU   r	  r   r   s       rX   test_reshape_with_neg_onez)TestParforNumPy.test_reshape_with_neg_one  T    	! 	! 	! H 4 4 4 5 5

9a#####rZ   c                 j    d }t          j        g d          }d}|                     |||           d S )Nc                     t          j        ||dft           j                  }| d|         }|j        } | dz  }|                    dd          }||z  }||d d d d df<   |S )Nr   r&  r   ir>  r?  s         rX   r	  z>TestParforNumPy.test_reshape_with_large_neg.<locals>.test_impl  su    HaAYbjAAAMacFE
AAAeQ''A!)K#.M!!!AAAa%   rZ   rD  r  rH  rI  s       rX   test_reshape_with_large_negz+TestParforNumPy.test_reshape_with_large_neg  rK  rZ   c                 B   |                      t          j                  5 }t          d          d             }t	          j        g d          }d} |||           d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )NTparallelc                     t          j        ||dft           j                  }| d|         }|j        } | dz  }|                    dd          }||z  }||d d d d df<   |S r=  r>  )r   r   rmrA  rB  rC  s         rX   r	  zETestParforNumPy.test_reshape_with_too_many_neg_one.<locals>.test_impl  ss    Xq!Qirz:::!A#JEMM"b))#ai'111QQQq5		rZ   rD  r  z7The reshape API may only include one negative argument.)	r  r   UnsupportedRewriteErrorr   r   r  r   r#  r  )rU   raisedr	  r   r   r   s         rX   "test_reshape_with_too_many_neg_onez2TestParforNumPy.test_reshape_with_too_many_neg_one  s    v=>> 	&4     !   8 8 8 9 9AAIaOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	" Ic3v/0011111s   >A**A.1A.c                 `    d }|                      |t          j        d          d           d S )Nc                     t          j        |           t          j        |           z   t          j        |           z   t          j        |           z   t          j        |           z   S r\   )r   r~  prodr  r  r  r  s    rX   r	  z0TestParforNumPy.test_0d_array.<locals>.test_impl  sD    6!99rwqzz)BF1II5q		ABF1IIMMrZ      Fr   )r   r   r  r  s     rX   test_0d_arrayzTestParforNumPy.test_0d_array  s:    	N 	N 	N

9bhqkkE
BBBBBrZ   c           	          d }t          j        d          dz  }|                     ||           |                     t	          |t
          j        d d d         f          d           d S )Nc                 P    t          j        | j        dz  | j        dz  z             S r}  )r   r~  realimag)rB  s    rX   r	  z6TestParforNumPy.test_real_imag_attr.<locals>.test_impl  s#    6!&A+!3444rZ   r   y      ?      ?r   )r   r  r   r   r   r   r)  )rU   r	  rB  s      rX   test_real_imag_attrz#TestParforNumPy.test_real_imag_attr  sp    	5 	5 	5 IaLLF#

9a   i%2B33Q32G1IJJANNNNNrZ   N)ry   rP   rz   r[  r>   r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r*  r6  r:  rJ  rN  rV  r\  ra  r~   rZ   rX   r  r  z  s       11$ $ Z$	G 	G 	GF F F. . . 
/ 
/ 
/9 9 9 9 9 9$9 9 9&F F FF F F$F F F"#: #: #:J#: #: #:J": ": ":H": ": ":H< < << < <$ $ $$$ $ $$2 2 2,C C C
O O O O OrZ   r  c                   X    e Zd ZdZ ej        e d          ed                         ZdS )TestParforsUnsupportedz$Tests for unsupported use of parforszOnly impacts 32 bit hardwarec                    |                      t          j                  5 }t          d          d             }t	          j        ddd                              dd          }t	          j        ddd          } |||           d	d	d	           n# 1 swxY w Y   d
}|                     |t          |j	                             d	S )zu
        This test is in place until issues with the 'parallel'
        target on 32 bit hardware are fixed.
        TrP  c                 ,    t          j        | |          S r\   r]  r  s     rX   ddotzHTestParforsUnsupported.test_unsupported_combination_raises.<locals>.ddot  s    va||#rZ   r   r   rC  r   r  NzCThe 'parallel' target is not currently supported on 32 bit hardware)
r  r   UnsupportedParforsErrorr   r   r   r  r   r#  r  )rU   rU  rf  r  r  r   s         rX   #test_unsupported_combination_raisesz:TestParforsUnsupported.test_unsupported_combination_raises  s    v=>> 	&4   $ $ ! $ Aq"%%--a44AAq"%%ADAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	c3v/0011111s   A&BBBN)	ry   rP   rz   r[  unittestskipIfr=   r>   rh  r~   rZ   rX   rc  rc    sP        ..X_Z!?@@2 2 Z A@2 2 2rZ   rc  c                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zed             Zd Zd Zed             Zed             Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d  Z$d! Z%d" Z&d# Z'd$ Z(d% Z)d& Z*d' Z+d( Z,d) Z-d* Z.d+ Z/d, Z0d- Z1d. Z2d/ Z3d0 Z4d1 Z5d2 Z6d3 Z7d4 Z8d5 Z9d6 Z:d7 Z;d8 Z<d9 Z=d: Z>d; Z?d< Z@d= ZAd> ZBd? ZCd@ ZDdA ZEdB ZFdC ZGdD ZHdE ZIdF ZJdG ZKdHS )ITestParforsz6 Tests cpython, reduction and various parfors featuresc                 @     d }                      | fd           d S )Nc                     | |z  |z   S r\   r~   )r   r   rl  s      rX   r	  z,TestParfors.test_arraymap.<locals>.test_impl  s    q519rZ   c                  .                          d          S Nr  r  r^   s   rX   r  z+TestParfors.test_arraymap.<locals>.<lambda>"  s    t/I/I!/L/L rZ   )r   r  s   ` rX   test_arraymapzTestParfors.test_arraymap  s:    	 	 	 	I'L'L'L'LMMMMMrZ   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S )Nr   r     )r   r  r  r~  rv  ru  s     rX   r	  z0TestParfors.test_0d_broadcast.<locals>.test_impl%  s0    A!!A6!a%== rZ   r~   r   r   r   r   r  s     rX   test_0d_broadcastzTestParfors.test_0d_broadcast$  K    	! 	! 	! 	

9i44a88888rZ   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S Nrt  )r   r  r4  r~  rv  s     rX   r	  z-TestParfors.test_2d_parfor.<locals>.test_impl-  s2    !!A""A6!a%== rZ   r~   r   rw  r  s     rX   test_2d_parforzTestParfors.test_2d_parfor,  ry  rZ   c                 z     d  fd}d }                      ||                                ||           d S )Nc               3   f   K   t          j        d          } t          j        d          }| |fV  d S r|  r   r  r4  rv  s     rX   case1z)TestParfors.test_nd_parfor.<locals>.case15  s5      !!A""Aa&LLLLLrZ   c                  Z    t                                            d                    S r}  )r   r  )r  rU   s   rX   r  z,TestParfors.test_nd_parfor.<locals>.<lambda>:  s%    5$*D*DQ*G*GHH rZ   c                 0    t          j        | |z             S r\   r  rv  s     rX   r	  z-TestParfors.test_nd_parfor.<locals>.test_impl<  s    6!a%== rZ   )r   r   )rU   r  r	  r  s   `  @rX   test_nd_parforzTestParfors.test_nd_parfor4  sj    	 	 	
 IHHHH	! 	! 	! 	Ix000##Ix88888rZ   c                 N    ddl m fd}d}|                     ||           d S )Nr   )r  c                 *     |           }|d         S r  r~   )r  r  r  s     rX   r	  z9TestParfors.test_np_func_direct_import.<locals>.test_implD  s    QAQ4KrZ   o   )r  r  r   )rU   r	  r  r  s      @rX   test_np_func_direct_importz&TestParfors.test_np_func_direct_importB  sO    	 	 	 	 	 

9a     rZ   c                 <   d }|                      |dd           |                     t                    5 } t          d          |          } |dd           d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )Nc                     t          j        |           }t          j        |          }t          j        ||z             S r\   r  )rE  r  r  r  s       rX   r	  z2TestParfors.test_size_assertion.<locals>.test_implK  s.    

A

A6!a%== rZ   r  TrP  	   zSizes of A, B do not match)r   r  r  r   r   r#  r  )rU   r	  r  r   r   s        rX   test_size_assertionzTestParfors.test_size_assertionJ  s    	! 	! 	!
 	

9b"%%%~.. 	&'D$'''	22EE"aLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 +c3v/0011111s   &A''A+.A+c                     d }d}t           j                            |          }t          j        |          }|                     ||||           d S )Nc                     t          j        d          D ]:}t          ||z  dz  |dz   |z  dz            D ]}d||<   | |         dk    rd||<   ;|S )Nr   r   r   r   r   r  )r   is_positiver  r  r  s        rX   r	  z'TestParfors.test_cfg.<locals>.test_implY  ss    \!__ + +!Q1a
44 + +A%&KNtaxx)*A+
 rZ   r  )r   r  randr4  r   )rU   r	  r  r   r  s        rX   test_cfgzTestParfors.test_cfgW  sV    	 	 	 INN1hqkk

9aa00000rZ   c           	      "   d }d}t           j                            |          }|                     ||           t           j                            d|                              t           j                  }|                     ||           d }|                                 5  |                     |           d d d            n# 1 swxY w Y   d}t           j                            d|                              t           j                  }d }|                     ||           d }|                     ||                    d	                     d
 }|                     ||                    d	                     | 	                    t          |t          j        d d d d f         f          d           d }|                     ||           | 	                    t          |t          j        d d          f          d           d S )Nc                 *    d}t          d | |          S )Nr  c                 "    t          | |          S r\   r	  r   s     rX   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>j  s    c!Qii rZ   r   )r  init_vals     rX   r	  z*TestParfors.test_reduce.<locals>.test_implh  s    H//H===rZ   r  r  r  c                  R    d } t          | t          j        g d          d          S )Nc                     | dz  S r}  r~   r1  s    rX   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>t  s
    !q& rZ   r   r   r  r  r   r   )r   r   r  )gs    rX   r	  z*TestParfors.test_reduce.<locals>.test_impls  s*      A!RXooo66:::rZ      c                 >    t          j        | | dk                       S rp  r  r  s    rX   r	  z*TestParfors.test_reduce.<locals>.test_impl|  s    6!AqD'??"rZ   c                 Z    | d d df         }t          j        | |dk    df                   S )Nr   r  r   r  r  r  s     rX   r	  z*TestParfors.test_reduce.<locals>.test_impl  s/    !!!A#A6!AqDF)$$$rZ   )   r  c                 ^    | d d df         }t          j        | |dk    ddf                   S )Nr   r  r   r   r  r  s     rX   r	  z*TestParfors.test_reduce.<locals>.test_impl  s3    !!!A#A6!AqD1H+&&&rZ   r   c                 4    t          j        |           }| |z
  S r\   )r   amin)r  min_vals     rX   r	  z*TestParfors.test_reduce.<locals>.test_impl  s    gajjGw;rZ   )r   r  r  r   r  r  r  assertTypingErrorr  r   r   r   r  rU   r	  r  r  s       rX   test_reducezTestParfors.test_reduceg  sL   	> 	> 	> INN1

9a   Ibq))00::

9a   	; 	; 	; ##%% 	" 	"JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" Ibq))00::	# 	# 	#

9a   	% 	% 	% 	

9aii00111	' 	' 	' 	

9aii00111i%-!!!2D1FGGKKK	 	 	 	

9a   i%-2B1DEEqIIIIIs   &CCCc                     d }d}|                      t                    5 }|                     |d          }d d d            n# 1 swxY w Y   |                     |t	          |j                             d S )Nc                  V    d} t          d          D ]}t          j        |           } | S r  )r   cmathr   accr  s     rX   r	  z9TestParfors.test_use_of_reduction_var1.<locals>.test_impl  s0    CAYY & &jooJrZ   CUse of reduction variable acc in an unsupported reduction function.r~   r  r   r   r   r#  r  rU   r	  r   r  r  s        rX   test_use_of_reduction_var1z&TestParfors.test_use_of_reduction_var1  s    	 	 	 Uz** 	:a**9b99F	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:c3q{++,,,,,   AA
Ac                     d }d}|                      t          j                  5 }|                     |d          }d d d            n# 1 swxY w Y   |                     |t          |j                             d S )Nc                  8    d} t          d          D ]}| dz  } | S Nr  r   r   r  s     rX   r	  z9TestParfors.test_unsupported_floordiv1.<locals>.test_impl  s,    CAYY  	JrZ   zParallel floordiv reductions are not supported. If all divisors are integers then a floordiv reduction can in some cases be parallelized as a multiply reduction followed by a floordiv of the resulting product.r~   )r  r   NumbaValueErrorr   r   r#  r  r  s        rX   test_unsupported_floordiv1z&TestParfors.test_unsupported_floordiv1  s    	 	 	(
 v566 	:!**9b99F	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:c3q{++,,,,,   AAAc                     d }d}|                      t                    5 }|                     |d          }d d d            n# 1 swxY w Y   |                     |t	          |j                             d S )Nc                  >    d} t          d          D ]
}| |dz   z  } | S r  r  r  s     rX   r	  z4TestParfors.test_unsupported_xor1.<locals>.test_impl  s0    CAYY  q1uJrZ   r  r~   r  r  s        rX   test_unsupported_xor1z!TestParfors.test_unsupported_xor1  s    	 	 	 Uz** 	:a**9b99F	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:c3q{++,,,,,r  c                     d }d}|                      ||           |                     t          |t          j        f          d           d S )Nc                 R    t          j        |           }|                                S r\   r  r  s     rX   r	  z8TestParfors.test_parfor_array_access1.<locals>.test_impl  s    

A5577NrZ   r  r   )r   r   r  r   r  rU   r	  r  s      rX   test_parfor_array_access1z%TestParfors.test_parfor_array_access1  sV    	 	 	 

9a   Y>>BBBBBrZ   c                     d }d}|                      ||           |                     t          |t          j        f          d           d S )Nc                    t          j        |           }d}d} t          j        t	          |                    D ]}|||         z  }t          j        t	          |                    D ]}|| k    r| ||         z  } || z   S r  )r   r  r   r   r   r  r  rE  r  s       rX   r	  z8TestParfors.test_parfor_array_access2.<locals>.test_impl  s    

AAA\#a&&))  QqT	\#a&&))  661IAq5LrZ   r  r   r   r   r  r   r  r  s      rX   test_parfor_array_access2z%TestParfors.test_parfor_array_access2  sX    	 	 	 

9a   4YNNPQRRRRRrZ   c                     d }d}|                      t          j                  5 }|                     ||           d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nc                     t          j        | t           j                  }d}t          j        t          |                    D ]}|||         z  }|dk    r|}d S Nr   r   )r   r  r  r   r   r   r  s       rX   r	  z8TestParfors.test_parfor_array_access3.<locals>.test_impl  s_    28$$AA\#a&&))  QqT	a44A rZ   r  z Overwrite of parallel loop index)r  r   rT  r   r   r#  r  )rU   r	  r  r  s       rX   test_parfor_array_access3z%TestParfors.test_parfor_array_access3  s    	 	 	 v=>> 	%&JJy!$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%8#f>N:O:OPPPPPr  c           	         d }d}d}t           j                            ||f          }t           j                            |          }|                     |||           t	          |t          j        t
          j        dd          t          j        t
          j        dd          f          \  }}|                     t          |j
                  dk    od|j
        v            |j
        d         }d}	d }
|j        D ]*}t          |t          j        j        j                  rd	}	|}
+|                     |	           d}|
j                                        D ]}}|j        D ]s}t          |t&          j                  rWt          |j        t&          j                  r8|j        j        d
k    r(d	}|                     |
j        |j        j        v            t~|                     |           d S )Nc                 ,    t          j        | |          S r\   r]  )r  r   s     rX   r	  z8TestParfors.test_parfor_array_access4.<locals>.test_impl  r  rZ   r  r  r   r  r   r   FTr  )r   r  r  r   r  r   r  r  rO  r   r  r  r   r   r  r  r  r  r  r   r  r  r  rT  r  rW  )rU   r	  r  dr  r   r  r  r  parfor_foundr  r  build_tuple_foundbls                 rX   test_parfor_array_access4z%TestParfors.test_parfor_array_access4  s   	  	  	  INNAq6""INN1

9a###,EM1c::EM1c::<= = 	GN++q0HQ'.5HIIIq!J 	 	D$ 4 ;<< #%%%!"))++ 	J 	JB J JtRY// J&tz27;;J JM]::(,%OOF$4
8H$HIIIJ 	)*****rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     t          j        t          |                     D ]}| j                            d          | |<    | d         S Nr   r  )r   r   r   r'  r   )r   r  s     rX   r	  z5TestParfors.test_parfor_dtype_type.<locals>.test_impl  sA    \#a&&)) ' 'w||A!Q4KrZ   r  r  )rU   r	  r   s      rX   test_parfor_dtype_typez"TestParfors.test_parfor_dtype_type  s:    	 	 	
 GBKK

9a     rZ   c                     d }d}|                      ||           |                     t          |t          j        f          d           d S )Nc                     t          j        | df          }d}t          j        |           D ]#}|||d d f                                         z  }$|S )Nr  r   )r   r  r   r   r~  )r  rv  rl  r  s       rX   r	  z8TestParfors.test_parfor_array_access5.<locals>.test_impl!  sT    AAA\!__ " "QqsVZZ\\!HrZ   r  r   r  r  s      rX   test_parfor_array_access5z%TestParfors.test_parfor_array_access5  sX    	 	 	 

9a   4YNNPQRRRRRrZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                 R    t          d          D ]}d| d         z  | d<   | d         S )Nr  r   r   r  )outr  s     rX   r	  z8TestParfors.test_parfor_hoist_setitem.<locals>.test_impl/  s3    BZZ $ $SVAq6MrZ   r   r  )rU   r	  r  s      rX   test_parfor_hoist_setitemz%TestParfors.test_parfor_hoist_setitem,  s:    	 	 	
 gajj

9c"""""rZ   c                 *   d }d}d}|                      |||           |                     t          |t          j        t          j        f          d           |                     t          |t          j        t          j        f          d           d S )Nc                     t          j        |          }t          j        | |f          }t          j        |           }t          d          D ]}| t          j        ||          z  }|S rp  )r   r  r  rt  )r  r  rw  rv  ru  r  r  s          rX   r	  z8TestParfors.test_parfor_generate_fuse.<locals>.test_impl:  s_    

AAA

A1XX ( (R"&A,,&HrZ   r  r  r  )r   r   r  r   r  r   )rU   r	  r  r  s       rX   test_parfor_generate_fusez%TestParfors.test_parfor_generate_fuse7  s    	 	 	 

9a###))ej%*5MNNPQRRRi%*ej1IJJANNNNNrZ   c                     d }t          j        dt           j                  }t          j        dt           j                  }d|d<   |                     |||           d S )Nc                 ,    t          j        | |          S r\   )r   bitwise_andr  s     rX   r	  z.TestParfors.test_ufunc_expr.<locals>.test_implK  s    >!Q'''rZ   r  r   r   )r   r  uint8r   )rU   r	  r  r  s       rX   test_ufunc_exprzTestParfors.test_ufunc_exprI  s^    	( 	( 	( GArx  GArx  !

9a#####rZ   c                 j    d }|                      t          |t          j        f          d           d S )Nc                 Z    t          | f          }t          |           D ]
}|dz   ||<   |S )Nr  )unsafe_emptyr  r  r  r  s      rX   r	  z;TestParfors.test_find_callname_intrinsic.<locals>.test_implT  s:    aT""A1XX  3w!HrZ   r   )r   r  r   r  r  s     rX   test_find_callname_intrinsicz(TestParfors.test_find_callname_intrinsicS  s>    	 	 	 	))ej]CCQGGGGGrZ   c                 8    d }|                      |d           d S )Nc                 f    d}t          |           D ]}|dz  }t          |           D ]}|dz  }|S r   r  r  r  r  s      rX   r	  z7TestParfors.test_reduction_var_reuse.<locals>.test_impl`  sL    CAYY  qAYY  qJrZ   r  r  r  s     rX   test_reduction_var_reusez$TestParfors.test_reduction_var_reuse^  s-    	 	 	 	

9b!!!!!rZ   c                     d }|                      |t          j        d          t          j        d                              d                     d S )Nc                 ^    d}t          | j        d                   D ]}||         r|dz  }|S Nr   r   r   r  )r  condr  r  s       rX   r	  z8TestParfors.test_non_identity_initial.<locals>.test_implm  s?    AAGAJ''  7 FAHrZ   r  boolr   r   r  r  r  s     rX   test_non_identity_initialz%TestParfors.test_non_identity_initialk  sM    	 	 	 	

9bgbkk272;;+=+=f+E+EFFFFFrZ   c                     d }|                      |t          j        d          t          j        d                              d                     d S )Nc                 ~    d}d}t          | j        d                   D ]}||         r|dz  }|dz  }|dz  }||z   S )Nr   r  r   r   r  )r  r  r  r  r  s        rX   r	  z9TestParfors.test_if_not_else_reduction.<locals>.test_implw  s]    AAAGAJ''  7 FAFAAFAAq5LrZ   r  r  r  r  s     rX   test_if_not_else_reductionz&TestParfors.test_if_not_else_reductionu  sM    		 		 		 	

9bgbkk272;;+=+=f+E+EFFFFFrZ   c                 8    d }|                      |d           d S )Nc                 (   d}|d         |d         z  }t          j        |t           j                  }t          j        |                              |          }t          j        |           D ]}||z  }t          j        |           D ]}||z  }|S N   r   r   r   r   r4  int_r  r  r   r   r  shpr  result1tmpr  s         rX   r	  z?TestParfors.test_two_d_array_reduction_reuse.<locals>.test_impl  s    Cq6CF?DhsBG,,G)D//))#..C\!__  3\!__  3NrZ   r  r  r  s     rX    test_two_d_array_reduction_reusez,TestParfors.test_two_d_array_reduction_reuse  s-    	 	 	 	

9c"""""rZ   c                 8    d }|                      |d           d S )Nc                     t          j        dt           j                  }t          j        |           D ]%}|t          j        |gt           j                  z  }&|S r"  )r   r4  r  r   r   r  )r  resultr  s      rX   r	  z9TestParfors.test_one_d_array_reduction.<locals>.test_impl  sM    Xa))F\!__ 1 1"(A3000MrZ   r  r  r  s     rX   test_one_d_array_reductionz&TestParfors.test_one_d_array_reduction  s-    	 	 	 	

9c"""""rZ   c                 8    d }|                      |d           d S )Nc                     d}|d         |d         z  }t          j        |t           j                  }t          j        |                              |          }t          j        |           D ]}||z  }|S r  r  r  s         rX   r	  z9TestParfors.test_two_d_array_reduction.<locals>.test_impl  sm    Cq6CF?DhsBG,,G)D//))#..C\!__  3NrZ   r  r  r  s     rX   test_two_d_array_reductionz&TestParfors.test_two_d_array_reduction  s-    		 		 		 	

9c"""""rZ   c                 8    d }|                      |d           d S )Nc                     d}t          j        |t           j                  }t          j        g d                              |          }t          j        |           D ]}||z  }|S )Nr  )r_  r  r   r  rE  rF  )r   r4  float32r  r  r   r   r  r  r  r   r  s        rX   r	  zJTestParfors.test_two_d_array_reduction_with_float_sizes.<locals>.test_impl  se    ChsBJ//G(999::BB3GGC\!__  3NrZ   r  r  r  s     rX   +test_two_d_array_reduction_with_float_sizesz7TestParfors.test_two_d_array_reduction_with_float_sizes  s-    	 	 	 	

9c"""""rZ   c                 8    d }|                      |d           d S )Nc                     d}dt          j        |t           j                  z  }dt          j        |          z  }t	          j        |           D ]}||z  }|S )Nr  r   )r   r  r  	ones_liker   r   r  s        rX   r	  z>TestParfors.test_two_d_array_reduction_prod.<locals>.test_impl  sZ    C"'#rw///Gbl7+++C\!__  3NrZ   r  r  r  s     rX   test_two_d_array_reduction_prodz+TestParfors.test_two_d_array_reduction_prod  s-    	 	 	 	

9c"""""rZ   c                 8    d }|                      |d           d S )Nc                     d}t          j        |t           j                  }t          j        |           D ]$}|t          j        |t           j                  z  }%|S )N)r  r   rZ  )r   r4  r  r   r   r  )r  r  r  r  s       rX   r	  z;TestParfors.test_three_d_array_reduction.<locals>.test_impl  sP    ChsBG,,G\!__ 1 1273000NrZ   r  r  r  s     rX   test_three_d_array_reductionz(TestParfors.test_three_d_array_reduction  s-    	 	 	 	

9c"""""rZ   c                 d    d }d}t          j        |          }|                     ||           d S )Nc                 0    |                                  dz   S r"  )argsortr  s    rX   r	  z>TestParfors.test_preparfor_canonicalize_kws.<locals>.test_impl  s    99;;?"rZ   r  r   r  r   r  s       rX   test_preparfor_canonicalize_kwsz+TestParfors.test_preparfor_canonicalize_kws  s?    	# 	# 	# IaLL

9a     rZ   c                    d }t          j        dt          j        d                    }|                     |t	          j        |          f          }|                     |                    |           ||                     d S )Nc                     | j         S r\   r&  r  s    rX   r	  z8TestParfors.test_preparfor_datetime64.<locals>.test_impl  s	    7NrZ   r   zdatetime64[ns])r   r  r'  r   r   r   r   r   )rU   r	  r  r   s       rX   test_preparfor_datetime64z%TestParfors.test_preparfor_datetime64  s    	 	 	 HQ!12233&&y5<??2DEE++A..		!=====rZ   c                 r    d }|                      |t          j                            d                     d S )Nc                     | j         d         }d}t          |          D ],}h d}|                    |           d}|D ]}||z  }||z  }-|S )Nr   >   r   r   r  )r  r   r  )rv  r  r  r  Rr   r   s          rX   r	  zITestParfors.test_no_hoisting_with_member_function_call.<locals>.test_impl  sn    
ACAYY  IIa  A1HCCs
JrZ   r  )r   r   r  r  r  s     rX   *test_no_hoisting_with_member_function_callz6TestParfors.test_no_hoisting_with_member_function_call  s;    
	 
	 
	 	

9binnS1122222rZ   c                 6    d }|                      |           dS )z issue3671: X != 0 becomes an arrayexpr with operator.ne.
            That is turned into a parfor by devectorizing.  Make sure
            the return type of the devectorized operator.ne
            on integer types works properly.
        c                  N    t          j        dt           j                  } | dk    S )Nr  r&  r   )r   r4  r  rv  s    rX   r	  z8TestParfors.test_array_compare_scalar.<locals>.test_impl  s!    27+++A6MrZ   Nr  r  s     rX   test_array_compare_scalarz%TestParfors.test_array_compare_scalar  s+    	 	 	 	

9rZ   c                 f    d }t          j        d          }|                     ||dd           d S )Nc                 z    t          |           }| d|         }|r| d|dz           }|                                S r  )r   r~  )r   halfr  parrs       rX   r	  z?TestParfors.test_array_analysis_optional_def.<locals>.test_impl  sA    q66DQtV9D $47|88::rZ   rC  TFr[  r  rU   r	  r   s      rX    test_array_analysis_optional_defz,TestParfors.test_array_analysis_optional_def  s@    	 	 	 GBKK

9a
>>>>>rZ   c                 j   d }t          j        dt                    }t          j        dt                    }|                     |||           |                     t          |t          j        t          j        dd          t          j        t          j        dd          f          d           d S )Nc                    t          j        t          |           t           j                  }t          |          }t	          j        |          D ]}| |         ||<   t	          j        |          D ]}||         ||         z   ||<   |S )Nr&  )r   r  r   r  r   r   )r   r   datar  r  s        rX   r	  z7TestParfors.test_prange_side_effects.<locals>.test_impl  s    8CFF"*555Dt99D\$''  A$Q\$'' ) )q'AaD.QKrZ   r  r&  r   r  )	r   r  floatr   r   r   r   r  r  )rU   r	  r   rl  s       rX   test_prange_side_effectsz$TestParfors.test_prange_side_effects  s    	 	 	 IgU+++IgU+++

9a###i%*[3%G%G%*[3%G%G%IJ JKL	N 	N 	N 	N 	NrZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     d}d}t          j        t          |                     D ]$}| |xx         |d         |d         z   |z   z  cc<   %| S )Nr  rZ  r   r   )r   r   r   r   atupr   r  s       rX   r	  z*TestParfors.test_tuple1.<locals>.test_impl!  sZ    DA\#a&&)) . .!Q$q')A--HrZ   r  r  r)  s      rX   test_tuple1zTestParfors.test_tuple1   :    	 	 	 IbMM

9a     rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     | j         }d}t          j        t          |                     D ]}| |xx         |d         |z   z  cc<   | S )NrZ  r   )r  r   r   r   r2  s       rX   r	  z*TestParfors.test_tuple2.<locals>.test_impl,  sR    7DA\#a&&)) $ $!Q!#HrZ   r  r  r)  s      rX   test_tuple2zTestParfors.test_tuple2+  r5  rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     t          j        d          df}d}t          j        t	          |                     D ]*}| |xx         |d         d         |d         z   |z   z  cc<   +| S )Nr  r  rZ  r   r   r   )r   r  r   r   r   r2  s       rX   r	  z*TestParfors.test_tuple3.<locals>.test_impl7  sk    IbMM1%DA\#a&&)) 1 1!Q
T!W,q00HrZ   r  r  r)  s      rX   test_tuple3zTestParfors.test_tuple36  r5  rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     t          dd          }d}t          j        t          |                     D ]"}| |xx         |j        |j        z   |z   z  cc<   #| S Nr  r  r   rZ  )r   r   r   r   r   r   )r   antupr   r  s       rX   r	  z/TestParfors.test_namedtuple1.<locals>.test_implB  sc    "!444EA\#a&&)) 6 6!ek1A55HrZ   r  r  r)  s      rX   test_namedtuple1zTestParfors.test_namedtuple1A  r5  rZ   c                     t          dd          fd}t          j        d          }|                     ||           d S )NTestNamedTuple2r   c                      dd          }d}t          j        t          |                     D ]"}| |xx         |j        |j        z   |z   z  cc<   #| S r>  )r   r   r   r   r   )r   r?  r   r  rB  s       rX   r	  z/TestParfors.test_namedtuple2.<locals>.test_implN  sf    #O!1555EA\#a&&)) 6 6!ek1A55HrZ   r  )r	   r   r  r   )rU   r	  r   rB  s      @rX   test_namedtuple2zTestParfors.test_namedtuple2L  sV    $%68JKK	 	 	 	 	 IbMM

9a     rZ   c                     t          ddg          }d }d } |t          j        d                    }|                     |||g           d S )NTestNamedTuple3rl  c                     d| j         d d <   d S )Nr   rl  r  s    rX   r	  z/TestParfors.test_namedtuple3.<locals>.test_impl]  s    ACFFFrZ   c                 Z    t           j                            | j        |j                   d S r\   )r   r   r   rl  r   s     rX   r  z.TestParfors.test_namedtuple3.<locals>.comparer`  s$    J**1344444rZ   r  rH  r  )r	   r   r4  r   )rU   rF  r	  r  r   s        rX   test_namedtuple3zTestParfors.test_namedtuple3X  sp     %%7>>	 	 		5 	5 	5 Obhrll+++

9aXJ
?????rZ   c                 Z   d }t          j        d          dz   }t          j        d          dz   }|                     |||           |                     t	          |t          j        t
          j        dd          t          j        t
          j        dd          f          d           d S )Nc                     || z  }|S r\   r~   r   s     rX   r	  z1TestParfors.test_inplace_binop.<locals>.test_implg  s    FAHrZ   r  r  r   r  )r   r  r   r   r   r   r  r  rU   r	  rv  ru  s       rX   test_inplace_binopzTestParfors.test_inplace_binopf  s    	 	 	 IbMMBIbMMC

9a###i%*[3%G%G%*[3%G%G%IJ JKL	N 	N 	N 	N 	NrZ   c                 d    d }t          j        ddg          }|                     ||           d S )Nc                     t          |           }||f}t          j        d|z   dz   t          j                  }|dd d f         }t	          |           D ]\  }}||||f<   |S )Nr  r&  r   r   r   r4  uint64r  r   r  array_shapeindicesk_listr  r  s          rX   r	  z0TestParfors.test_tuple_concat.<locals>.test_implt  st    AAQ$Kh{ 2T 9")LLLGQT]F!! ! !1 q!tMrZ   r   rH  r)  s      rX   test_tuple_concatzTestParfors.test_tuple_concatr  s@    	 	 	 HaV

9a     rZ   c                 d    d }t          j        ddg          }|                     ||           d S )Nc                     t          |           }||f}t          j        d|z   dz   d d         t          j                  }|dd d f         }t	          |           D ]\  }}||||f<   |S )Nr  rK   r&  r   rQ  rS  s          rX   r	  zCTestParfors.test_tuple_concat_with_reverse_slice.<locals>.test_impl  s    AAQ$Kh{ 2T 93B3?%'Y0 0 0GQT]F!! ! !1 q!tMrZ   r   rH  r)  s      rX   $test_tuple_concat_with_reverse_slicez0TestParfors.test_tuple_concat_with_reverse_slice  s@    		 		 		 HaV

9a     rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                 F    | f| | fz   }|d                                          S r  r~  )r   Ss     rX   r	  z6TestParfors.test_array_tuple_concat.<locals>.test_impl  s#    1vAQ488::rZ   r  r  r  r)  s      rX   test_array_tuple_concatz#TestParfors.test_array_tuple_concat  s:    	 	 	 GENN

9a     rZ   c                 `    d }t          j        d          }|                     ||           d S )Nc                     | dz  S )NrE  r~   r1  s    rX   r	  z3TestParfors.test_high_dimension1.<locals>.test_impl  s    s7NrZ   )r   r   r   r   r      r  r)  s      rX   test_high_dimension1z TestParfors.test_high_dimension1  s;    	 	 	G'((

9a     rZ   c                 b    d }d}|                      |t          j        |          |           d S )Nc                 >    t          j        |          D ]}d| |<   | S r"  r   pndindexr   szr  s      rX   r	  z-TestParfors.test_tuple_arg.<locals>.test_impl  +    ^B''  !HrZ   r  r   )r   r   r  rU   r	  rj  s      rX   test_tuple_argzTestParfors.test_tuple_arg  s<    	 	 	 

9bhrllB/////rZ   c                 b    d }d}|                      |t          j        |          d           d S )Nc                 >    t          j        |          D ]}d| |<   | S r"  rg  ri  s      rX   r	  z=TestParfors.test_tuple_arg_not_whole_array.<locals>.test_impl  rk  rZ   rl  r  r  r   r   r4  rm  s      rX   test_tuple_arg_not_whole_arrayz*TestParfors.test_tuple_arg_not_whole_array  s<    	 	 	 

9bhrllG44444rZ   c                 `    d }d}|                      |t          j        |                     d S )Nc                 B    d}t          j        |          D ]}d| |<   | S )Nrl  r   rg  ri  s      rX   r	  z6TestParfors.test_tuple_for_pndindex.<locals>.test_impl  s0    B^B''  !HrZ   rl  rr  rm  s      rX   test_tuple_for_pndindexz#TestParfors.test_tuple_for_pndindex  s:    	 	 	
 

9bhrll+++++rZ   c                 b    d }d}|                      |t          j        |          d           d S )Nc                 F    |df}t          j        |          D ]}d| |<   | S r  rg  )r   firstrj  r  s       rX   r	  z5TestParfors.test_tuple_arg_literal.<locals>.test_impl  s4    B^B''  !HrZ   rl  r  rr  rm  s      rX   test_tuple_arg_literalz"TestParfors.test_tuple_arg_literal  s<    	 	 	
 

9bhrllB/////rZ   c                      d d d                          fd}t           t          d          fD ]} ||           d S )Nc                 >    t          j        |          D ]}d| |<   | S r"  rg  ri  s      rX   r	  z?TestParfors.test_tuple_of_literal_nonliteral.<locals>.test_impl  rk  rZ   c                      || d          S )Nrq  r~   )r   r2  s     rX   rN  z:TestParfors.test_tuple_of_literal_nonliteral.<locals>.call  s    2a>>!rZ   c                  *    t          j        d          S )Nr9  r   r4  r~   rZ   rX   r  z>TestParfors.test_tuple_of_literal_nonliteral.<locals>.<lambda>  s    BHX.. rZ   c                      |           }t                    } |             |          }                    |           d S r\   )r   assertPreciseEqual)	decf1f2gotrN  expected	get_inputrU   r	  s	       rX   r   z;TestParfors.test_tuple_of_literal_nonliteral.<locals>.check  sN    YBdB"YY[["%%C##Hc22222rZ   TrP  r   )rU   r   r  rN  r  r  r	  s   `  @@@@rX    test_tuple_of_literal_nonliteralz,TestParfors.test_tuple_of_literal_nonliteral  s    	 	 	
	" 	" 	" /.	4		Y//	3 	3 	3 	3 	3 	3 	3 	3 	3 d+++, 	 	AE!HHHH	 	rZ   c                 b    d }d}|                      |t          j        |          |           d S )Nc                 >    t          j        |          D ]}d| |<   | S r"  rg  ri  s      rX   r	  z0TestParfors.test_tuple_arg_1d.<locals>.test_impl  rk  rZ   r  rr  rm  s      rX   test_tuple_arg_1dzTestParfors.test_tuple_arg_1d  s<    	 	 	 

9bhrllB/////rZ   c                 `    d }d}|                      |t          j        |                     d S )Nc                 B    d}t          j        |          D ]}d| |<   | S Nr  r   rg  ri  s      rX   r	  z8TestParfors.test_tuple_arg_1d_literal.<locals>.test_impl  s0    B^B''  !HrZ   r  rr  rm  s      rX   test_tuple_arg_1d_literalz%TestParfors.test_tuple_arg_1d_literal  s:    	 	 	
 

9bhrll+++++rZ   c                 ^    d }|                      |t          j        d          d           d S )Nc                 >    t          j        |          D ]}d| |<   | S r"  rg  ri  s      rX   r	  z4TestParfors.test_int_arg_pndindex.<locals>.test_impl  rk  rZ   r9  r  rr  r  s     rX   test_int_arg_pndindexz!TestParfors.test_int_arg_pndindex  s9    	 	 	 	

9bhx00!44444rZ   c                 "   t           d             fd}d}t          j        ||f          }t          j        d d d d df         t
          j        f}|                     t          ||          d           | 	                    |||           d S )Nc                 v    t          ||z   dz   dz  dz   |dz
  d          D ]}| |dz   |f         dz   | ||f<   d S Nr   r   r  )ur  evenr  r  s        rX   issue7854_procz=TestParfors.test_prange_unknown_call1.<locals>.issue7854_proc  s\    D1HqLA-14!8Q?? * *AE1H+/!Q$* *rZ   c                     t          j        d|dz
            D ]} | |d|           t          j        d|dz
            D ]} | |d|           | S r  r   r   )r  r  r  r  s      rX   r	  z8TestParfors.test_prange_unknown_call1.<locals>.test_impl  sx    \!TAX.. . .q!Q----\!TAX.. . .q!Q----HrZ   r  r   r   )
rC   r   r4  r   r  r   r  r   r   r   )rU   r	  r  r  cptypesr  s        @rX   test_prange_unknown_call1z%TestParfors.test_prange_unknown_call1  s    		* 	* 
		*	 	 	 	 	 HdD\""=CCaC(%+6i991===

9a&&&&&rZ   c                     d }d}t          j        ||f          }t          j        d d d d df         t          j        f}|                     t          ||          d           |                     |||           d S )Nc                 @   t          j        d|dz
            D ]7}t          |dz   dz  dz   |dz
  d          D ]}| |dz   |f         dz   | ||f<   8t          j        d|dz
            D ]4}t          |dz  dz   |dz
  d          D ]}| |dz   |f         dz   | ||f<   5| S r  r  )r  r  r  r  s       rX   r	  z6TestParfors.test_prange_index_calc1.<locals>.test_impl  s    \!TAX.. . .A{Qq!<< . .AAqkAoAadGG.\!TAX.. . .q1uqy$(A66 . .AAqkAoAadGG.HrZ   r  r   r   	r   r4  r   r  r   r  r   r   r   )rU   r	  r  r  r  s        rX   test_prange_index_calc1z#TestParfors.test_prange_index_calc1  s    	 	 	 HdD\""=CCaC(%+6i991===

9a&&&&&rZ   c                 Z   d }d}t          j        ||f          }t          j        ||f          }t          j        d d d d df         t          j        d d d d df         t          j        f}|                     t          ||          d           |                     ||||           d S )Nc                     t          j        |          D ]&}t          |          D ]}|||f         dz   | ||f<   't          j        |          D ]}t          |          D ]	}d|||f<   
| d         |d         z   S )Nr   r  r4  r  )r   r   r  r  r  s        rX   r	  z9TestParfors.test_prange_reverse_order1.<locals>.test_impl  s    \$'' * *t * *A1gkAadGG*\$''    t    AAadGG T7QtW$$rZ   r  r   r   r  rU   r	  r  r   r   r  s         rX   test_prange_reverse_order1z&TestParfors.test_prange_reverse_order1  s    	% 	% 	% HdD\""HdD\""=CCaC(%-33Q3*?Mi991===

9aD)))))rZ   c                     d }d}t          j        |          }t          j        d d          t          j        f}|                     t          ||          d           |                     |||           d S )Nc                     d}t          j        |          D ]}|| |<   t          j        |          D ]}|| d         z  }|S )Nr   r   r  )r   r  r   r  s       rX   r	  z@TestParfors.test_prange_parfor_index_then_not.<locals>.test_impl0  sX    A\$''  !\$''  QqT	HrZ   r  r   r  )rU   r	  r  r   r  s        rX   !test_prange_parfor_index_then_notz-TestParfors.test_prange_parfor_index_then_not-  sx    	 	 	 HTNN=#U[1i991===

9a&&&&&rZ   c                 `   d }d}t          j        |          }t          |          }t          j        d d          t
          j                            t
          j        |          t
          j        f}| 	                    t          ||          d           |                     ||||           d S )Nc                     d}t          j        |          D ]}|||         z   | |<   t          j        |          D ]}|| |         |d         z   z  }|S r  r  )r   tupr  r  r  s        rX   r	  zJTestParfors.test_prange_parfor_index_const_tuple_fusion.<locals>.test_implA  si    C\$'' " "3q6z!\$'' % %qtc!f}$JrZ   r  r   )r   r4  r   r   r  r   
containersUniTupler  r   r   r   r  s         rX   +test_prange_parfor_index_const_tuple_fusionz7TestParfors.test_prange_parfor_index_const_tuple_fusion>  s    	 	 	 HTNN!HH=##,,U]DAA: 	i991===

9aD)))))rZ   c                 >   d }d}t          j        |          }t          j        |          }t          j        d d          t          j        d d          t          j        f}|                     t          ||          d           |                     ||||           d S )Nc                     t          j        |          D ]}| d         ||<   t          j        |          D ]}|| |<   |dxx         | d         z  cc<   |S )Nr   r   r  )r   r   r  r  s       rX   r	  zITestParfors.test_prange_non_parfor_index_then_opposite.<locals>.test_implU  sl    \$''  t!\$''  !aDDDAaDLDDDHrZ   r  r   r  r  s         rX   *test_prange_non_parfor_index_then_oppositez6TestParfors.test_prange_non_parfor_index_then_oppositeR  s    	 	 	 HTNNHTNN=#U]111%5u{Ci991===

9aD)))))rZ   c                     dd}t          j        d          }|                     ||d t           j        j        d g           |                     |                                d           d S )Nc                 8    t          d          D ]	}|d| |<   
d S )Nr   r  r  )arrpredr  s      rX   r	  z3TestParfors.test_prange_optional.<locals>.test_implf  s1    AYY ! !# CF! !rZ   r  c                     | |k    S r\   r~   r   rl  s     rX   r  z2TestParfors.test_prange_optional.<locals>.<lambda>n  s
    AF rZ   r  rG  r\   )r   r  r   r   r   r   r~  rU   r	  r  s      rX   test_prange_optionalz TestParfors.test_prange_optionale  s    	! 	! 	! 	!
 gbkk

9c4')z'E':':'< 	 	= 	= 	= 	D)))))rZ   c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                      d} | d         S )Ng333333?g?r   r~   r  s    rX   r	  z8TestParfors.test_untraced_value_tuple.<locals>.test_impls  s    AQ4KrZ   r
  r  r  s      rX   test_untraced_value_tuplez%TestParfors.test_untraced_value_tupleq  s    	 	 	 ~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLLr  c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                  "    d} | d         d         S )N)r  r   r~   r  s    rX   r	  zBTestParfors.test_recursive_untraced_value_tuple.<locals>.test_impl}  s    AQ47NrZ   r
  r  r  s      rX   #test_recursive_untraced_value_tuplez/TestParfors.test_recursive_untraced_value_tuple{  s    	 	 	 ~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLLr  c                    d }t          j        t           j        dd          f}|                     t	          ||          d           t          j        dt
          j                  }|                     ||           d S )Nc                    d}t          |           }t          j        |t          j                  }t	          |          D ]}| |         |d         z  ||<   t          |          }t          j        |t          j                  }t	          |          D ]}||         |d         z
  ||<   d}t          |          }	t	          |	          D ]}
|||
         z  }||d         z   S )Nr  r   r   r  r   r   r  r  r   )r  r   n1arr2r  n2arr3r  totaln3r   s              rX   r	  z9TestParfors.test_untraced_value_parfor.<locals>.test_impl  s    ASB8B
++DBZZ ( (a&1Q4-QTB8B
++DBZZ ) )q'AaD.QETBBZZ ! !a 1Q4<rZ   r   r  r  r&  )r   r  r  r   r   r   r  r   )rU   r	  r  r  s       rX   test_untraced_value_parforz&TestParfors.test_untraced_value_parfor  s{    	  	  	   {5;3//2i55q999i"(+++

9c"""""rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 h    d}t          | j        d                   D ]}|r| d| |d d f<   |dz  }| S r  )r  r  )r   rS  r  s      rX   r	  z;TestParfors.test_setitem_2d_one_replaced.<locals>.test_impl  sR    E171:&&   A%(
HrZ   )r  r   rr  r  s     rX   test_setitem_2d_one_replacedz(TestParfors.test_setitem_2d_one_replaced  s7    	 	 	 	

9bhv../////rZ   c                     d }t          j        d          }|                     ||dd           |                     ||dd           |                     ||dd           d S )Nc                     t          j        | j                  }|r|                    t           j                  S |r	||         }n||dz
           }|| j        z  S r"  )r   r  r  r  r  )r  flag1flag2invrets        rX   r	  z7TestParfors.test_1array_control_flow.<locals>.test_impl  s[    )CH%%C .zz"*--- ##h#'l>!rZ   r  TFr  r  s      rX   test_1array_control_flowz$TestParfors.test_1array_control_flow  sn    	" 	" 	" inn

9c4///

9c4...

9c5%00000rZ   c                     d }t          j        d          }|                     ||dd           |                     ||dd           d S )Nc                     t          j        | j                  }t          j        || j        |z             }|r	||         }n||dz
           }||z  S r"  r   r  r  )r  r  flaginv1inv2r  s         rX   r	  z9TestParfors.test_2array_1_control_flow.<locals>.test_impl  sT    9SX&&D9Q1--D %4j4!8n:rZ   r  r  TFr  r  s      rX   test_2array_1_control_flowz&TestParfors.test_2array_1_control_flow  sV    	 	 	 inn

9c2t,,,

9c2u-----rZ   c                     d }t          j        d          }|                     ||dd           |                     ||dd           d S )Nc                     t          j        | j                  }t          j        || j        |z             }|r||         }||         }n||dz
           }||dz
           }||z  S r"  r  )r  r  r  r  r  ret1ret2s          rX   r	  z9TestParfors.test_2array_2_control_flow.<locals>.test_impl  sj    9SX&&D9Q1--D &DzDzD1H~D1H~$;rZ   r  r  TFr  r  s      rX   test_2array_2_control_flowz&TestParfors.test_2array_2_control_flow  sV    		 		 		 inn

9c2t,,,

9c2u-----rZ   c                     d }|                      |d           |                     t          |t          j        f          d           d S )Nc                 ^   t          j        | t           j                  }t          j        | t           j                  }t          |           D ]$}t	          |          D ]}||xx         dz  cc<   %t          |           D ] }|dk    r	||         ||dz
           z
  ||<   !|dd          S )Nr&  r   r   )r   r4  r  r   r  )r  rcr  r  s        rX   r	  z-TestParfors.test_issue8515.<locals>.test_impl  s    "'***A"'***AAYY  q  AaDDDAIDDDD AYY ' '66taAh!QRR5LrZ   rc  r   )r   r   r   r   r  r  s     rX   test_issue8515zTestParfors.test_issue8515  sQ    	 	 	 	

9b!!!i%+AA1EEEEErZ   N)Lry   rP   rz   r[  rq  rx  r}  r  r  r  r  r  r  r  r  r  r  r  r>   r  r  r  r@   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r$  r*  r/  r4  r8  r;  r@  rD  rJ  rN  rW  rZ  r`  rd  rn  rs  rv  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r~   rZ   rX   rl  rl    s       @@N N N9 9 99 9 99 9 9! ! !2 2 21 1 1 .J .J .J`- - -- - -"
- 
- 
-	C 	C 	CS S S(Q Q Q $+ $+ Z$+L! ! !S S S # # ]# O O ZO"$ $ $	H 	H 	H" " "G G GG G G# # #"	# 	# 	## # ## # ## # #
# 
# 
#! ! !> > >3 3 3
 
 

? 
? 
?N N N$	! 	! 	!	! 	! 	!	! 	! 	!	! 	! 	!
! 
! 
!@ @ @
N 
N 
N! ! !! ! ! ! ! !! ! !0 0 05 5 5, , ,0 0 0  00 0 0, , ,5 5 5' ' '*' ' '$* * *&' ' '"* * *(* * *&
* 
* 
*M M MM M M# # #00 0 01 1 1". . .. . ."F F F F FrZ   rl  c                        e Zd Zd Zd Zd ZdS )TestParforsLeaksc                 N     | j         |g|R  \  }} | j        |||g|R i | d S r\   r   r   s         rX   r   zTestParforsLeaks.check  M    ((7$777v$$VUFLTLLLVLLLLLrZ   c                     t          d          d             }t          j        d                              t          j                  }|                     ||           d S )NTrP  c                 *    |                                  S r\   r]  )r  s    rX   r	  z2TestParforsLeaks.test_reduction.<locals>.test_impl  s    7799rZ   r  r   r   r  r  r  r   r  s      rX   test_reductionzTestParforsLeaks.test_reduction  s`    	t				 	 
		 imm""2:..

9c"""""rZ   c                     t          d          d             }t          j        d                              t          j                  }|                     ||           d S )NTrP  c                 z    d}d}t          | j                  D ]}|| |         z  }|d| |         dz   z  z  }||z  S )Nr  r_  r   )r   r  )r  r   r   r  s       rX   r	  z@TestParforsLeaks.test_multiple_reduction_vars.<locals>.test_impl	  sT    AACH%% ' 'SVR3q6A:&&q5LrZ   r  r  r  s      rX   test_multiple_reduction_varsz-TestParforsLeaks.test_multiple_reduction_vars 	  s`    	t				 	 
		 imm""2:..

9c"""""rZ   N)ry   rP   rz   r   r  r  r~   rZ   rX   r  r    sD        M M M# # #
# 
# 
# 
# 
#rZ   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	e
d             Ze
d	             Ze
d
             Zd Zd Zd Zd Zd Ze
d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestParforsSlicec                 \    d }|                      |t          j        d                     d S )Nc                 N    | j         \  }| d|dz
           | d|dz
           z   }|S Nr   r   r   r  r   r  r   s      rX   r	  z6TestParforsSlice.test_parfor_slice1.<locals>.test_impl	  s2    7DQ!AaC%1QqsU8#AHrZ   r  r   r   r  r  s     rX   test_parfor_slice1z#TestParforsSlice.test_parfor_slice1	  s5    	 	 	
 	

9bgbkk*****rZ   c                 |   d }|                      |t          j        d          d           |                     t                    5 }  t          d          |          t          j        d          d           d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nc                 H    | j         \  }| d|dz
           | d|         z   }|S r  r  r   rE  r  r   s       rX   r	  z6TestParforsSlice.test_parfor_slice2.<locals>.test_impl	  s.    7DQ!AaC%1QqS6!AHrZ   r  r  TrP  do not match	r   r   r  r  r  r   r   r#  r  r  s      rX   test_parfor_slice2z#TestParforsSlice.test_parfor_slice2	  s    	 	 	 	

9bgbkk1---~.. 	;&*D$	**272;;r:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;nc&*:&;&;<<<<<s   6B		BBc                 \    d }|                      |t          j        d                     d S )Nc                 `    | j         \  }}| d|dz
  d|dz
  f         | d|d|f         z   }|S r  r  r  s       rX   r	  z6TestParforsSlice.test_parfor_slice3.<locals>.test_impl&	  sD    GEQq!AaC%!A#+1Q3qs7+AHrZ   r  r  r  r  s     rX   test_parfor_slice3z#TestParforsSlice.test_parfor_slice3%	  5    	 	 	
 	

9bgenn-----rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 Z    | j         \  }}| d d d|dz
  f         | d d d|f         z   }|S r  r  r  s       rX   r	  z6TestParforsSlice.test_parfor_slice4.<locals>.test_impl.	  s@    GEQq!!!AacE'
Qqqq1uX%AHrZ   r  r  r  s     rX   test_parfor_slice4z#TestParforsSlice.test_parfor_slice4-	  r  rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 Z    | j         \  }}| d|dz
  d d f         | d|d d f         z   }|S r  r  r  s       rX   r	  z6TestParforsSlice.test_parfor_slice5.<locals>.test_impl6	  s@    GEQq!AaC%'
Qqs111uX%AHrZ   r  r  r  s     rX   test_parfor_slice5z#TestParforsSlice.test_parfor_slice55	  r  rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 `    |                                  }| dd d f         |d d df         z   }|S r"  	transposer   r   r  s      rX   r	  z6TestParforsSlice.test_parfor_slice6.<locals>.test_impl>	  s5    A!AAA#111Q3AHrZ   r  r  r  s     rX   test_parfor_slice6z#TestParforsSlice.test_parfor_slice6=	  r  rZ   c                 x   d }|                      |t          j        d                     |                     t                    5 }  t          d          |          t          j        d                     d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nc                 `    |                                  }| dd d f         |dd d f         z   }|S r"  r  r  s      rX   r	  z6TestParforsSlice.test_parfor_slice7.<locals>.test_implF	  s5    A!AAA#1QQQ3AHrZ   r_  TrP  r  r  r  r  s      rX   test_parfor_slice7z#TestParforsSlice.test_parfor_slice7E	  s    	 	 	 	

9bgenn---~.. 	;&*D$	**275>>:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;nc&*:&;&;<<<<<s   5BBBc                     d }|                      |t          j        d                              d                     d S )Nc                 p    | j         \  }}|                                 }| d|d|f         |d|d|f<   |S r"  r  r  r  s       rX   r	  z6TestParforsSlice.test_parfor_slice8.<locals>.test_implT	  sD    GEQqA1Q3qs7Aac!A#gJHrZ   r  r_  r   r   r  r  r  s     rX   test_parfor_slice8z#TestParforsSlice.test_parfor_slice8R	  C    	 	 	 	

9bill22599:::::rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 p    | j         \  }}|                                 }| d d d|f         |d|d|f<   |S r"  r  r  s       rX   r	  z6TestParforsSlice.test_parfor_slice9.<locals>.test_impl^	  sD    GEQqA111QqS5Aac!A#gJHrZ   ru  r  r  r  s     rX   test_parfor_slice9z#TestParforsSlice.test_parfor_slice9\	  sC    	 	 	 	

9bimm33E::;;;;;rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dd|f         |dd|f<   |S r  r  r  s       rX   r	  z7TestParforsSlice.test_parfor_slice10.<locals>.test_implh	  s<    GEQqA1Q3xAa!eHHrZ   r  r_  r  r  s     rX   test_parfor_slice10z$TestParforsSlice.test_parfor_slice10f	  r  rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 v    | j         \  }}}|                                 }| d d dd|f         |d d dd|f<   |S r  r  r   )r   rE  r  r  r   s        rX   r	  z7TestParforsSlice.test_parfor_slice11.<locals>.test_implq	  sJ    gGQqA111Qqs7Aaaa!A#gJHrZ      )r  r  r  r  r  s     rX   test_parfor_slice11z$TestParforsSlice.test_parfor_slice11p	  sC    	 	 	 	

9bimm33G<<=====rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dd df         |dddf<   |S )Nr   r   rK   r#  r  s       rX   r	  z7TestParforsSlice.test_parfor_slice12.<locals>.test_implz	  s<    GEQqA!CRC%Aa"fIHrZ   ru  r  r  r  s     rX   test_parfor_slice12z$TestParforsSlice.test_parfor_slice12y	  C    	 	 	 	

9bimm33E::;;;;;rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 t    | j         \  }}|                                 }d}| d| |dz
  f         |dd|f<   |S )NrK   r   r   r#  )r   rE  r  r   r  s        rX   r	  z7TestParforsSlice.test_parfor_slice13.<locals>.test_impl	  sG    GEQqAAA2ac6{Aa!eHHrZ   ru  r  r  r  s     rX   test_parfor_slice13z$TestParforsSlice.test_parfor_slice13	  sC    	 	 	 	

9bimm33E::;;;;;rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dddf         |dd df<   |S )Nr   r  r   rK   r#  r  s       rX   r	  z7TestParforsSlice.test_parfor_slice14.<locals>.test_impl	  s<    GEQqA2a4yAaeHHrZ   ru  r  r  r  s     rX   test_parfor_slice14z$TestParforsSlice.test_parfor_slice14	  r*  rZ   c                     d }|                      |t          j        d                              d                     d S )Nc                 p    | j         \  }}|                                 }| dddf         |d|dz
   d f<   |S )Nr   r0  r  r   r#  r  s       rX   r	  z7TestParforsSlice.test_parfor_slice15.<locals>.test_impl	  sB    GEQqAQr!tV9Aa!A#iLHrZ   ru  r  r  r  s     rX   test_parfor_slice15z$TestParforsSlice.test_parfor_slice15	  r*  rZ   c                 2   d }|                      |t          j        d          t          j        d          d           t          j        dd         t          j        dd         t          j        f}|                     t          ||          d           dS )z This test is disabled because if n is larger than the array size
            then n and n-1 will both be the end of the array and thus the
            slices will in fact be of different sizes and unable to fuse.
        c                 R    | j         |j         k    sJ d| d|<   d|d|dz
  <   | |z  S Nr  r   r   r  )r   r   r  s      rX   r	  z7TestParforsSlice.test_parfor_slice16.<locals>.test_impl	  s>    7ag%%%%AacFAa1gJq5LrZ   r     Nr   )	r   r   r  r4  r   r  r  r   r   rU   r	  r   s      rX   test_parfor_slice16z$TestParforsSlice.test_parfor_slice16	  s    	 	 	 	

9bgbkk28B<<;;;aaa %-"2EK@i66:::::rZ   c                 ^    d }|                      |dt          j        d                     d S )Nc                 \    t          j        |           }t          |          }||| d <   |S r\   r   r4  r   )rE  r  r  r  s       rX   r	  z7TestParforsSlice.test_parfor_slice17.<locals>.test_impl	  s.    AAAAqbccFHrZ   r  r  r  s     rX   test_parfor_slice17z$TestParforsSlice.test_parfor_slice17	  s7    	 	 	 	

9b"'"++.....rZ   c                 6    d }|                      |           d S )Nc                  r    t          j        d          } t          j        dd          | dd<   | d         }|S )Nr  r   rZ  r   r8  r  )r   r4  r  )r   rl  s     rX   r	  z7TestParforsSlice.test_parfor_slice18.<locals>.test_impl	  s4    AYq!__AacF!AHrZ   r  r  s     rX   test_parfor_slice18z$TestParforsSlice.test_parfor_slice18	  s+    	 	 	 	

9rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 *    | d dxx         dz  cc<   | S r  r~   r#  s    rX   r	  z7TestParforsSlice.test_parfor_slice19.<locals>.test_impl	  s     bqbEEEQJEEEHrZ   r  r  r  s     rX   test_parfor_slice19z$TestParforsSlice.test_parfor_slice19	  5    	 	 	 	

9bgbkk*****rZ   c                 :    d }|                      |d           d S )Nc                  `    t          j        d          } | dd          }t          |          }|S )Nr  r   )r   r  r   )r   r  r  s      rX   r	  z7TestParforsSlice.test_parfor_slice20.<locals>.test_impl	  s,    A!""AAAHrZ   Fr[  r  r  s     rX   test_parfor_slice20z$TestParforsSlice.test_parfor_slice20	  s/    	 	 	 	

9u
55555rZ   c                     d }t           j                            d          }t           j                            d          }|                     |||           d S )Nc                     |                      | j        d          } |                     |j        d          }| |d dd d f         k    S )Nr   rK   )r  r  )x1x2s     rX   r	  z7TestParforsSlice.test_parfor_slice21.<locals>.test_impl	  sG    BGQ''BBGQ''BCRCF##rZ   r   r  )r   r  r  r   rU   r	  rK  rL  s       rX   test_parfor_slice21z$TestParforsSlice.test_parfor_slice21	  sU    	$ 	$ 	$
 Y^^AY^^A

9b"%%%%%rZ   c                     d }t          j        d          }t          j        d          }|                     |||           d S )Nc                 p    t          j        d          }t          d          D ]}|| d d |f         z  }|S r  )r   r4  r   )rK  rL  r   r  s       rX   r	  z7TestParforsSlice.test_parfor_slice22.<locals>.test_impl	  s@    AAYY  R2YHrZ   )r  rZ  r  )r   r4  r  r   rM  s       rX   test_parfor_slice22z$TestParforsSlice.test_parfor_slice22	  sK    	 	 	 XfXa[[

9b"%%%%%rZ   c                 \    d }|                      |t          j        d                     d S )Nc                     d| d d<   | S )Nr   r   r~   r1  s    rX   r	  z7TestParforsSlice.test_parfor_slice23.<locals>.test_impl	  s    AbqbEHrZ   r  r  r  s     rX   test_parfor_slice23z$TestParforsSlice.test_parfor_slice23	  rE  rZ   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }||d          }|d t          |                   }|S r\   r=  rE  r  r  r  r  s        rX   r	  z7TestParforsSlice.test_parfor_slice24.<locals>.test_impl	  s4    A!""A'3q66'
AHrZ   rc  r  r  r   r   r  rU   r	  r  s      rX   test_parfor_slice24z$TestParforsSlice.test_parfor_slice24	  W    	 	 	 sB 	6 	6AJJy"bgbkk15555	6 	6rZ   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }|d |         }|d t          |                   }|S r\   r=  rW  s        rX   r	  z7TestParforsSlice.test_parfor_slice25.<locals>.test_impl	  s4    A"1"A'3q66'
AHrZ   rX  rc  r  rY  rZ  s      rX   test_parfor_slice25z$TestParforsSlice.test_parfor_slice25	  r\  rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 f    | j         \  }|                                 }| dd         ||dz
   d <   |S )Nr0  r  r   r#  r  s      rX   r	  z7TestParforsSlice.test_parfor_slice26.<locals>.test_impl
  s8    7DQA2a4A!fggJHrZ   r  r   r   r  r  s     rX   test_parfor_slice26z$TestParforsSlice.test_parfor_slice26
  s5    	 	 	 	

9bill+++++rZ   c                 \    d }|                      |t          j        d                     d S )Nc                 ~    d}t          | j        d                   D ]}| |         dk    r|dz  }|r
| d |         } dS r  r  )r   n_valid_valsr  unuseds       rX   r	  z7TestParforsSlice.test_parfor_slice27.<locals>.test_impl
  sW    LAGAJ'' . .Q4199 A%L .}}-F1rZ   r  rb  r  s     rX   test_parfor_slice27z$TestParforsSlice.test_parfor_slice27
  s5    
	 
	 
	 	

9bill+++++rZ   c           	      z   t          ddd           t          dd d           t          d dd          t          d d d           t          d d d          fD ]ffd}d}|                     ||           t          j        |dz                                |df          }fd	}|                     ||           gd S )
Nr   r  r   rK   r(  c                     t          j        | dz                                | df          }d}t          j        |           D ]!}|||f                                         z  }"|S Nr  r   )r   r  r  r   r   r~  )r  rv  rl  r  tss       rX   r	  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl"
  se    Ia!e$$,,aV44a ( (A1b5'AArZ   r  r  c                     d}t          j        | j        d                   D ]!}|| |f                                         z  }"|S r  )r   r   r  r~  )rv  rl  r  rl  s      rX   r	  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl.
  sH    agaj11 ( (A1b5'AArZ   )slicer   r   r  r  )rU   r	  r  rv  rl  s       @rX   $test_parfor_array_access_lower_slicez5TestParforsSlice.test_parfor_array_access_lower_slice
  s    At$$eAtT&:&:E$2<N<NtT**E$b,A,AC 	% 	%B     AJJy!$$$	!a%  ((!Q00A     JJy!$$$$+	% 	%rZ   N) ry   rP   rz   r  r   r  r  r  r  r  r@   r  r  r   r%  r)  r-  r1  r4  r:  r>  rA  rD  rH  rN  rQ  rT  r[  r_  rc  rh  ro  r~   rZ   rX   r  r  	  s       + + += = =. . .. . .. . .. . .= = = ; ; ]; < < ]< ; ; ];> > >< < << < << < << < < ; ; ];/ / /  + + +6 6 6& & &	& 	& 	&+ + +6 6 66 6 6, , ,, , ,"% % % % %rZ   r  c                       e Zd Zd ZdS )TestParforsOptionsc                    d }|                      |t          j        d                     t          j        d d          f}|                     t          ||          d           |                     t          ||d          d           |                     t          ||dd          d           |                     t          ||ddd	          d
           |                     t          ||dddd          d           |                     t          ||ddddd          d           |                     t          ||dddddd          d           d S )Nc                 $   | j         d         }t          j        |          }t          j        d t	          |          D                       }| ||z  z   |d |<   t          |          D ]}||         | |         z  ||<   t          d |d          S )Nr   c                     g | ]}|S r~   r~   )r   r  s     rX   r   zMTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<listcomp>>
  s    0001000rZ   c                     | |z   S r\   r~   r  s     rX   r  zKTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<lambda>B
  s
    QqS rZ   )r  r   r  r  r  r   r   )r   r  r   r  r  s        rX   r	  z9TestParforsOptions.test_parfor_options.<locals>.test_impl;
  s    
A

A00eAhh00011AAIAbqbEAYY # #tad{!..!Q///rZ   r  r   F)fusionr  )rv  comprehensionr   )rv  rw  setitemr  )rv  rw  rx  r   r  )rv  rw  rx  r   	reductionr   )rv  rw  rx  r   ry  r  r   )r   r   r  r   r  r   r   r9  s      rX   test_parfor_optionsz&TestParforsOptions.test_parfor_options:
  s   	0 	0 	0 	

9bgbkk***aaa "i66:::ieDDDaHHHie',. . ./0	2 	2 	2 	ie',e= = =>?	A 	A 	A 	ie',eEK K KLM	O 	O 	O 	ie',eE#(* * *+,	. 	. 	. 	ie',eE#(7 7 789	; 	; 	; 	; 	;rZ   N)ry   rP   rz   rz  r~   rZ   rX   rq  rq  7
  s#         ;  ;  ;  ;  ;rZ   rq  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestParforsBitMaskc                 ^    d }|                      |t          j        d          d           d S )Nc                     | |k    }d| |<   | S r  r~   r  s      rX   r	  z:TestParforsBitMask.test_parfor_bitmask1.<locals>.test_impla
  s    AAAaDHrZ   r  r   rb  r  s     rX   test_parfor_bitmask1z'TestParforsBitMask.test_parfor_bitmask1`
  s7    	 	 	
 	

9bimmQ/////rZ   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                     d| |<   | S r  r~   r   s     rX   r	  z:TestParforsBitMask.test_parfor_bitmask2.<locals>.test_impli
      AaDHrZ   r  r   r  rI  s       rX   test_parfor_bitmask2z'TestParforsBitMask.test_parfor_bitmask2h
  E    	 	 	 IbMME

9a#####rZ   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                     | |         | |<   | S r\   r~   r   s     rX   r	  z:TestParforsBitMask.test_parfor_bitmask3.<locals>.test_implr
  s    Q4AaDHrZ   r  r   r  rI  s       rX   test_parfor_bitmask3z'TestParforsBitMask.test_parfor_bitmask3q
  r  rZ   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 "    d| z  |         | |<   | S r}  r~   r   s     rX   r	  z:TestParforsBitMask.test_parfor_bitmask4.<locals>.test_impl{
  s    E1:AaDHrZ   r  r   r  rI  s       rX   test_parfor_bitmask4z'TestParforsBitMask.test_parfor_bitmask4z
  r  rZ   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 .    | |         | |         z  | |<   | S r\   r~   r   s     rX   r	  z:TestParforsBitMask.test_parfor_bitmask5.<locals>.test_impl
  s    Q4!A$;AaDHrZ   r  r   r  rI  s       rX   test_parfor_bitmask5z'TestParforsBitMask.test_parfor_bitmask5
  r  rZ   c                 f   d }t          j        d          }|dk    }t          j        t          |                    }|                     t
                    5 }|                     ||||           d d d            n# 1 swxY w Y   |                     dt          |j	                             d S )Nc                     || |<   | S r\   r~   r  s      rX   r	  z:TestParforsBitMask.test_parfor_bitmask6.<locals>.test_impl
  r  rZ   r  r   r
  )
r   r  r4  r~  r  r  r   r   r#  r  )rU   r	  r   r   r  r  s         rX   test_parfor_bitmask6z'TestParforsBitMask.test_parfor_bitmask6
  s    	 	 	 IbMMEHSVV ~.. 	+&JJy!Q***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+4c&:J6K6KLLLLLs   A>>BBN)	ry   rP   rz   r  r  r  r  r  r  r~   rZ   rX   r|  r|  ]
  ss        0 0 0$ $ $$ $ $$ $ $$ $ $M M M M MrZ   r|  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zed             Zd Zd Zd Zd Zd Zd Zed             Zd Zd Zd ZdS )TestParforsMiscz?
    Tests miscellaneous parts of ParallelAccelerator use.
    c                 
   d } t          dd          |          }t          j        d          5 }t          j        d           t          j        dd           t          j        dd	t
          j        j        d
            |             d d d            n# 1 swxY w Y   |                     t          |          d           d |j
                                        D             }|                     |dg           d S )Nc                  |    t          j        d          } t          | j                  D ]}| |xx         |z  cc<   | S Nr  )r   r  r   r  )r  r  s     rX   r   z9TestParforsMisc.test_no_warn_if_cache_set.<locals>.pyfunc
  sD    '#,,CCH%%  A!JrZ   T)rQ  cacherecordalwaysignore	typeguard)actionmodulez.*TBB_INTERFACE_VERSION.*znumba\.np\.ufunc\.parallel.*)r  messagecategoryr  r   c                 &    g | ]}|j         j        S r~   )r   has_dynamic_globals)r   r   s     rX   r   z=TestParforsMisc.test_no_warn_if_cache_set.<locals>.<listcomp>
  s3     E E E#'  $|? E E ErZ   F)r   warningscatch_warningssimplefilterfilterwarningsr   r   NumbaWarningr   r   	overloadsr  )rU   r   r   raised_warningsr  s        rX   test_no_warn_if_cache_setz)TestParforsMisc.test_no_warn_if_cache_set
  ss   	 	 	 0d$///77$D111 		_!(+++#8+68 8 8 8 #8,H-2\-F+JL L L L EGGG		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 	_--q111E E+0?+A+A+C+CE E E,ug66666s   ABB"Bc                 *   d }|                      |d          }t                      5 }|                                 d d d            n# 1 swxY w Y   |                                                                D ]}|                     d|           d S )Nc                      t          j        d          } t          j        dd          | dd<   t          d| d                    t          d| d                    | S )Nr  r   rZ  r   r8  za[3]:r  )r   r4  r  printr  s    rX   r   zITestParforsMisc.test_statement_reordering_respects_aliasing.<locals>.impl
  sS    AYq!__AacF'1Q4   '1Q4   HrZ   r~   z	a[3]: 2.0)r   r7   r   getvaluer@  r   )rU   r   r   stdoutlines        rX   +test_statement_reordering_respects_aliasingz;TestParforsMisc.test_statement_reordering_respects_aliasing
  s    	 	 	 $$T2.. 	&	 	 	 	 	 	 	 	 	 	 	 	 	 	 	OO%%0022 	0 	0D[$////	0 	0s   A		AAc                    d }t          j        t           j        dg          } t          d          |          }t          j        j        j        }	 dt          j        j        _        t           j        	                     ||           ||                     |t          j        j        _        d S # |t          j        j        _        w xY w)Nc                 *    t          j        |           S r\   )r   isinfr  s    rX   r	  z;TestParforsMisc.test_parfor_ufunc_typing.<locals>.test_impl
  s    8A;;rZ   r  TrP  )
r   r  r  r   r   r  r  sequential_parfor_loweringr   assert_array_equal)rU   r	  r  r   old_seq_flags        rX   test_parfor_ufunc_typingz(TestParforsMisc.test_parfor_ufunc_typing
  s    	 	 	 Hbfc]###d###I..}+F	K>BEM ;J))))A,,aAAA ?KEM ;;;lEM ;JJJJs   AB4 4Cc                 T    d }|                      t          |d          d           d S )Nc                      d} g d}t           j        j                                         |}t          j        d          D ]}| ||         z  } | |d         z   S )Nr   r  r   r   )r   r  r  init_pranger   )resr  dummyr  s       rX   r	  z6TestParforsMisc.test_init_block_dce.<locals>.test_impl
  s`    C++CM ,,...E\!__  s1vq>!rZ   r~   r   )r   r  r  s     rX   test_init_block_dcez#TestParforsMisc.test_init_block_dce
  s:    	" 	" 	" 	,Y;;Q?????rZ   c                 6    d }|                      |           d S )Nc                  b    d} t          d          D ]}| dz  } t          j        | f          }|S )Nr   r  r   r  r   r4  )r  rL   r-  s      rX   r	  zBTestParforsMisc.test_alias_analysis_for_parfor1.<locals>.test_impl
  s=    C1XX  q8SF##DKrZ   r  r  s     rX   test_alias_analysis_for_parfor1z/TestParforsMisc.test_alias_analysis_for_parfor1
  s+    	 	 	 	

9rZ   c                 :   dt          dd           G fddt                                 G fddt                    }t          d|	          d
             }|                     t
          j        j        j                   | 	                    t          j                  5 } |             d d d            n# 1 swxY w Y   |                     t          |j                             |                     t
          j        j        j                   d S )N
BROKEN_MSGTF)mutates_CFGanalysis_onlyc                   $    e Zd ZdZd Z fdZdS )VTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParforsbreak_parforsc                 .    t          j        |            d S r\   )r4   r   r^   s    rX   r   z_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.__init__
  s    %d+++++rZ   c                     |j         j                                        D ]V}|j        D ]J}t	          |t
          j        j        j                  r$ G fddt                    } |            |_
        K dS d S )Nc                       e Zd Z fdZdS )oTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_pass.<locals>.Brokenc                 ,    t          j                  r\   )r   LoweringError)rU   otherr  s     rX   
differencezzTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_pass.<locals>.Broken.difference  s    *0*>z*J*J$JrZ   N)ry   rP   rz   r  r  s   rX   Brokenr  	  s5        !K !K !K !K !K !K !KrZ   r  T)r  r  r  r  r   r   r  r  r  r   races)rU   r  blkr  r  r  s        rX   run_passz_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_pass
  s     =/6688    C # 2 2%dEM,@,GHH 2K K K K K K K K K K
 *0DJ44   rZ   N)ry   rP   rz   _namer   r  r  s   rX   BreakParforsr  
  sB        #E, , ,             rZ   r  c                       e Zd Z fdZdS )^TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParforsCompilerc                     t          j        | j                  }|                    t                     |                                 |gS r\   )r2   define_nopython_pipeliner  add_pass_afterr5   finalize)rU   pmr  s     rX   define_pipelineszoTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParforsCompiler.define_pipelines  s?    '@LL!!,???trZ   N)ry   rP   rz   r  )r  s   rX   BreakParforsCompilerr    s.              rZ   r  )rQ  pipeline_classc                  8    d} t          d          D ]}| dz  } | S r"  r  )r   rL   s     rX   foozMTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.foo  s,    AAYY  QHrZ   )r3   r4   r1   r   assertFalser   r  r  r  r  r   r  r   r#  r  )rU   r  r  r  r  r  s       @@rX   0test_no_state_change_in_gufunc_lowering_on_errorz@TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error
  s   
 "
	4u	=	=	=	  	  	  	  	  	  	 < 	  	  
>	=	 2	 	 	 	 	 	 	< 	 	 	 
t,@	A	A	A	 	 
B	A	 	-HIIIv344 	CEEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	j#f&6"7"7888 	-HIIIIIs   (B??CCc                   	  G d dt           j                  } |d          	 t          |          t          j                    G d dt
                    }t          j        |          	fd            }t          |          d             }t          |dd	d
i          d             }t          d             t          fd            }t          j        j        j        }|                     |           	  | |                       |                     t          j        j        j                   |t          j        j        _        d S # |t          j        j        _        w xY w)Nc                       e Zd ZdS )2TestParforsMisc.test_issue_5098.<locals>.DummyTypeNry   rP   rz   r~   rZ   rX   	DummyTyper  .          DrZ   r  my_dummyc                       e Zd ZdS ).TestParforsMisc.test_issue_5098.<locals>.DummyNr  r~   rZ   rX   Dummyr  4  r  rZ   r  c                     S r\   r~   )valr  
dummy_types     rX   typeof_Dummyz5TestParforsMisc.test_issue_5098.<locals>.typeof_Dummy7  s	    rZ   c                 N    t          |j                                                  S r\   )r"   contextget_dummy_value)typobjr  s      rX   unbox_indexz4TestParforsMisc.test_issue_5098.<locals>.unbox_index;  s    qy88::;;;rZ   method1rQ  T)jit_optionsc                     d }|S )Nc                 "   d }t          |          }t          j        |t          j                  }t	          |          D ]} |||         |          ||<   t	          |dz
            D ]"}||xx          |||         |          z  cc<   #|S )Nc                     |                                  }t          j        |t          j        |           <    ||          S r\   )r   r   r"  r  )r   fr  s      rX   bazzPTestParforsMisc.test_issue_5098.<locals>._get_method1.<locals>._foo.<locals>.bazB  s/    A%'VAbhqkkN1Q44KrZ   r&  r   r  )r  r  r   r   length
output_arrr  s          rX   _foozCTestParforsMisc.test_issue_5098.<locals>._get_method1.<locals>._fooA  s         
 SXfBJ???
 6 6A$'CA$5$5JqMM
++ 7 7AqMMMSSQ%6%66MMMM!!rZ   r~   )r  r  r   r  s       rX   _get_method1z5TestParforsMisc.test_issue_5098.<locals>._get_method1?  s    " " " KrZ   c                 *    |                                  S r\   r  )r  s    rX   barz,TestParforsMisc.test_issue_5098.<locals>.barP  s    6688OrZ   c                 `    |                      t          j        g dg dg                    S )Nr_  r  r   )r  rE  rF  )r  r   r  )r  r  s    rX   test1z.TestParforsMisc.test_issue_5098.<locals>.test1T  s.    99RX&HII3OOOrZ   )r   Opaquer   r#   OpaqueModelobjectr    registerr!   r   r   r   r  r  r  r  )
rU   r  r  r  r  r  r	  
save_stater  r  s
           @@rX   test_issue_5098zTestParforsMisc.test_issue_5098-  s   	 	 	 	 	 	 	 	 Yz**
!y!!&"4555	 	 	 	 	F 	 	 	 
	e	$	$	 	 	 	 
%	$	 
y			< 	< 
		< 
IJt;L	M	M	M	 	 
N	M	  
	 	 
	 
	P 	P 	P 	P 
	P ])D
$$$	IE%%''NNNU]1LMMM ?IEM ;;;jEM ;HHHHs   =<E E)c                    t          d          d             }t          dd          5  |                     t          j                  5 } |d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |j                  }|                     d|           |                     d|           d S )	NTrP  c                 H    d}d}t          d          D ]}|||          z  }|S )N)r   r   r  r  r   r  r  )idxbig_tuprB  r   s       rX   oversize_tuplezMTestParforsMisc.test_oversized_tuple_as_arg_to_kernel.<locals>.oversize_tupled  s6    GABZZ " "WS\!HrZ   NUMBA_PARFOR_MAX_TUPLE_SIZE3r   zUse of a tuplezin a parallel region)r   r9   r  r   rg  r#  r  r   )rU   r  r  errstrs       rX   %test_oversized_tuple_as_arg_to_kernelz5TestParforsMisc.test_oversized_tuple_as_arg_to_kernelb  sJ   	t				 	 
		 !!>DD 	" 	"""6#ABB "fq!!!" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" V%&&&///,f55555s5    A9
A"A9"A&	&A9)A&	*A99A= A=c                     d }d}t           j                            dd|          }t           j                            dd|          }|                     |||           d S )Nc                    d}t          j        | j        || j                  }| j        }t	          |d                   D ]J}t	          |d                   D ]2}| ||f         |||f         z
  | ||f         |||f         z   z  |||f<   3K|S Nr   r&  r   )r   fullr  r'  r   )img_nirimg_red	fillvalueout_imgdimsrl  r   s          rX   	ndvi_njitz1TestParforsMisc.test_issue5167.<locals>.ndvi_njitv  s    IggmYgmLLLG=DDG__ F FQ F FA&-admgadm&C&-admgadm&C&EGAqDMMF NrZ   )r  r  r_  g     @)lowr  r  )r   r  uniformr   )rU   r"  
tile_shapearray1array2s        rX   test_issue5167zTestParforsMisc.test_issue5167t  sl    	 	 	 
""sz"JJ""sz"JJ

9ff-----rZ   c                 V   d }t           d             }t          j                            d          }  t          d          |          |                                |d          } ||                                |d          }t          j                            ||           d S )Nc                 :   t          j        | j        d         | j        d         ft           j                  }t	          | j        d                   D ]G}t          |dz   | j        d                   D ]&} || |         | |         g|R  }||||f<   ||||f<   'H|S r  )r   r4  r  r  r   r  )r   r  	dist_argsr  r  r  r  s          rX   
reproducerz2TestParforsMisc.test_issue5065.<locals>.reproducer  s    Xqwqz171:6bjIIIFAGAJ'' % %q1uagaj11 % %AQqT1Q44)444A#$F1a4L#$F1a4LL% MrZ   c                     d}t          | j        d                   D ]}|| |         ||         z
  dz  z  }t          j        |          S )Nr  r   r   )r  r  r   r   )r   rl  r  r  s       rX   	euclideanz1TestParforsMisc.test_issue5065.<locals>.euclidean  sO    F171:&& - -1Q4!A$;1,,76??"rZ   )r   r   r  TrP  r~   )r   r   r  r   r   r   )rU   r,  r.  r   r  r  s         rX   test_issue5065zTestParforsMisc.test_issue5065  s    	 	 	 
	# 	# 
	# I&))-!dD!!!*--affhh	"EE:affhh	"55

""311111rZ   c                     d }t          j        d          t          j        d          f}|                     ||           d S )Nc                     dgt          |           z  }t          t          |                     D ]}t          | |                   ||<   |S r  )r   r   )myarrayr  r  s      rX   test_numba_parallelz;TestParforsMisc.test_issue5001.<locals>.test_numba_parallel  sK    S3w<<'FCLL)) , ,
OOq		MrZ   r  2   )r   r  r   )rU   r3  r2  s      rX   test_issue5001zTestParforsMisc.test_issue5001  sH    	 	 	 8C==".

&00000rZ   c                 ~    t           d             t          d          fd            } |dgfdz             d S )Nc                     d S r\   r~   )gridss    rX   r  z+TestParforsMisc.test_issue3169.<locals>.foo  s    DrZ   TrP  c                 B    t          d          D ]} |            d S r"  r  )r8  r   r  s     rX   r  z+TestParforsMisc.test_issue3169.<locals>.bar  s1    AYY  E



 rZ   r   r   r  )rU   r  r  s     @rX   test_issue3169zTestParforsMisc.test_issue3169  sh    		 	 
	 
t				 	 	 	 
		
 	aSFQJrZ   c                     t          dd          }fd}t          d          d              |dd          }|                     ||           d S )	Nmytyper   c                 N    t          d          D ]} ||            | j        S rp  )r   r   )mydatar   inners     rX   outerz-TestParforsMisc.test_issue4846.<locals>.outer  s4    AYY ! !a    8OrZ   T)nogilc                 *    | |j         f}| |j        f}d S r\   r   )r   r>  r  r  s       rX   r?  z-TestParforsMisc.test_issue4846.<locals>.inner  s    FHAFHAAArZ   r   r   )r	   r   r   )rU   r<  r@  r>  r?  s       @rX   test_issue4846zTestParforsMisc.test_issue4846  s     Hj11	 	 	 	 	
 
D				 	 
		 #%%%

5&!!!!!rZ   c                 6    d }|                      |           d S )Nc                  b    d} d}t          t          |                     D ]}|| |         z  }|S )Nr  r   )r   r   )r   r   r  s      rX   test1bz.TestParforsMisc.test_issue3748.<locals>.test1b  s;    AACFF^^  QqT	HrZ   r  )rU   rF  s     rX   test_issue3748zTestParforsMisc.test_issue3748  s+    	 	 	 	

6rZ   c                 t    d }d}t          j        |t                    }|                     |||           d S )Nc                     t          | d                   D ]+}t          | d                   D ]}|dz  |z   ||         |<   ,|S )Nr   r   g      @r  )r  r  r   rl  s       rX   parallel_testz5TestParforsMisc.test_issue5277.<locals>.parallel_test  sU    DG__ , ,Q , ,A !C!CF1II,JrZ   r9  r&  )r   r4  intr   )rU   rJ  r  r  s       rX   test_issue5277zTestParforsMisc.test_issue5277  sH    	 	 	 ht3'''

=$,,,,,rZ   c                     t          d          d             }t          j        d          }d}t          j        d          }|                      ||||          |                    |||                     d S )NTrP  c                 j    t          d          D ]}t          d          D ]	}d|||f<   
|r|dz  }|S r"  )r   r  )r  methodr  r  r  s        rX   r  z5TestParforsMisc.test_issue5570_ssa_races.<locals>.foo  sV    AYY " "q " "A !C1II" qJrZ   )r   r   9   r9  )r   r   r4  r  py_func)rU   r  r  rO  r  s        rX   test_issue5570_ssa_racesz(TestParforsMisc.test_issue5570_ssa_races  s    	t				 	 
		 huoohvCVS!!KKVS))	
 	
 	
 	
 	
rZ   c                    t          d          d             }t          j                            d           t          j                            d          }|                      ||          |                    |                     d S )NTrP  c                 r    | }t          dd          D ]}||d d d d f         }t          j        |          S )Nr   r  )r  r   r  )r   packager  z_stacks       rX   find_maxima_3D_jitzDTestParforsMisc.test_issue6095_numpy_max.<locals>.find_maxima_3D_jit  sF    Gq" / /!%AAA+.6'??"rZ   r   )r  r  r  )r   r   r  r  r  rQ  )rU   rW  r   s      rX   test_issue6095_numpy_maxz(TestParforsMisc.test_issue6095_numpy_max  s    	t				# 	# 
		# 		qy--t$$&&t,,	
 	
 	
 	
 	
rZ   c                     d }d}d}t          j        ||ft           j                  }t          j        ||ft           j                  }|                     |||           d S )Nc                     | j         }|d         }t          |          D ]'}| |d d f         ||d d f<   ||dfxx         dz  cc<   (|S r  )r  r   )gggg_nextgsr  i_ggs        rX   r	  z3TestParforsMisc.test_issue5942_1.<locals>.test_impl  sm    B1Aq		 & &$&tQQQwKaaa a   A%    NrZ   r  r   r&  )r   r4  r  r   )rU   r	  r  r   r[  r\  s         rX   test_issue5942_1z TestParforsMisc.test_issue5942_1  sm    	 	 	 (Aq628444(Aq628444

9b'*****rZ   c                 B    d }d}d}|                      |||           d S )Nc                 .   t          j        | |ft           j                  }t          j        | |ft           j                  }t          |           D ]@}t	          |          D ]	}||||f<   
||d d f         ||d d f<   ||dfxx         dz  cc<   A|S )Nr&  r   r   )r   r4  r  r   r  )r  r   r[  r\  r^  r  s         rX   r	  z3TestParforsMisc.test_issue5942_2.<locals>.test_impl  s    h1vrx888Bh1vrx888Gq		 & &q ' 'A"&BtQwKK$&tQQQwKaaa a   A%    NrZ   r  r   r  )rU   r	  r  r   s       rX   test_issue5942_2z TestParforsMisc.test_issue5942_2  s9    
	 
	 
	 

9a#####rZ   c                     t          d          d             }t          j        g dg dg          }|                      ||          |                    |                     d S )NTrP  c                 |   t          | j        d                   D ]}t          j        }t          j        g dt          j                  }dD ]Y}t          j                            | |d d f         |z             }||k     r%|}t          j        |||gt          j                  }Z| |d d fxx         |z  cc<   | S )Nr   )r   r   r   r&  )r   r   rK   )r   r  r   r  r  r  rX  norm)r  r   r  trr  dist_ts         rX   r  z)TestParforsMisc.test_issue6102.<locals>.f.  s    QWQZ((  vXiiirz:::# C CAY^^Ab!!!eHqL99F}}%Xq!QirzBBB"aaa%BHrZ   )r  r  r  )r  r  r_  )r   r   r  r  rQ  )rU   r  r  s      rX   test_issue6102zTestParforsMisc.test_issue6102*  su     
t			
	 
	 
	
	 HlllLLL122!aiill33333rZ   c                 b    t          d          d             }|                     |           d S )NTrP  c                      d} t          j        | f          }t          j        | dz
  f          }t          t	          |                    D ]$}t          j        |||dz                      ||<   %|S r  )r   r  r  r   r   r~  )r  na_maskr  r  s       rX   r	  z1TestParforsMisc.test_issue6774.<locals>.test_impl?  so    AgqdmmGXq1uh''FCKK(( 5 5F71QU7#344q		MrZ   )r   r   r  s     rX   test_issue6774zTestParforsMisc.test_issue6774>  sA    	t				 	 
		 	

9rZ   c                 6    d }|                      |           d S )Nc                  F    t          j        t          t          f          } | S r\   )r   r4  _GLOBAL_INT_FOR_TESTING1_GLOBAL_INT_FOR_TESTING2)bufs    rX   r	  z9TestParforsMisc.test_issue4963_globals.<locals>.test_implK  s    (46NOPPCJrZ   r  r  s     rX   test_issue4963_globalsz&TestParforsMisc.test_issue4963_globalsJ  s+    	 	 	 	

9rZ   c                 H    ddfd}|                      |           d S )Nr   r   c                  4    t          j        f          } | S r\   r  )rq  _FREEVAR_INT_FOR_TESTING1_FREEVAR_INT_FOR_TESTING2s    rX   r	  z:TestParforsMisc.test_issue4963_freevars.<locals>.test_implS  s    (57PQRRCJrZ   r  )rU   r	  ru  rv  s     @@rX   test_issue4963_freevarsz'TestParforsMisc.test_issue4963_freevarsP  sH    $&!$%!	 	 	 	 	 	 	

9rZ   N)ry   rP   rz   r[  r  r  r  r  r  r  r  r  r(  r/  r5  r:  r@   rC  rG  rL  rR  rX  r_  rb  rA   rh  rl  rr  rw  r~   rZ   rX   r  r  
  s        7 7 780 0 0K K K@ @ @	 	 	:J :J :Jx3I 3I 3Ij6 6 6$. . ."2 2 22	1 	1 	1   " " ]"$	 	 	- - -
 
 
&
 
 
+ + +&$ $ $& 4 4 4&
 
 
      rZ   r  c                   ^    e Zd Zd Zd Zd Z	 	 	 ddZd Zd Zd Z	d	 Z
d
 Zd Zd Zd ZdS )TestParforsDiagnosticsc                 N     | j         |g|R  \  }} | j        |||g|R i | d S r\   r   r   s         rX   r   zTestParforsDiagnostics.check\  r  rZ   c                     |                      |          }|                      |          }|                     ||           d S r\   )_fusion_equivalentr   )rU   r  r  r   r   s        rX   assert_fusion_equivalencez0TestParforsDiagnostics.assert_fusion_equivalence`  sD    ##C((##H--ArZ   c                     t          t                    }t          |                                          t	          |                                          D ]}fd||         D             ||z
  <   |S )Nc                     g | ]}|z
  S r~   r~   )r   r   min_keys     rX   r   z=TestParforsDiagnostics._fusion_equivalent.<locals>.<listcomp>p  s    >>>G>>>rZ   )r   r   r  keyssorted)rU   thingnewr   r  s       @rX   r|  z)TestParforsDiagnostics._fusion_equivalente  st     $ejjll##

%% 	? 	?A>>>>U1X>>>CG
rZ   Nc                 t   |(|                      ||                                           ||                     ||j                   ||                     ||j                   |H|j                                        }|D ],}|D ]}	|	d         |k    r nd|d|}
t          |
          -|7|                                }|                      |t          |                     t                      5  t          dd          D ]}|                    |           	 d d d            d S # 1 swxY w Y   d S )Nr   zReplacement for z was not found. Had r   r   )r   count_parforsr}  fusion_infonested_fusion_infor  r  r  hoisted_allocationsr   r7   r  dump)rU   r  parfors_countr  r  r  r  replr   replacedr   hoisted_allocss               rX   assert_diagnosticsz)TestParforsDiagnostics.assert_diagnosticss  s    $]K,E,E,G,GHHH"**;8OPPP)**+=+6+IK K K#+2244D! . . $ . .H{a'' (. IJ44PC(--- 
 *(<<>>N0#n2E2EFFF  	$ 	$1a[[ $ $  ####$	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   6)D--D14D1c                     d }|                      |           |                     |d          }|j        d         }|                     |ddddgi           d S )	Nc                  `    d} t          j        |           }t          j        |           }||z   S Nr  r  r  r   r   s      rX   r	  z9TestParforsDiagnostics.test_array_expr.<locals>.test_impl  s*    A

AAq5LrZ   r~   parfor_diagnosticsr   r  r  r   )r  r  r   r   r  r  rU   r	  r   r  s       rX   test_array_exprz&TestParforsDiagnostics.test_array_expr  s}    	 	 	 	

9&&y"55o&:;1/01a&k 	  	; 	; 	; 	; 	;rZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                  f    d} t          j        |           }t          |           D ]
}|dz  ||<   |S r  r   r  r   )r  r   r  s      rX   r	  z5TestParforsDiagnostics.test_prange.<locals>.test_impl  s=    AAAYY  2v!HrZ   r~   r  r   r  r  r  s       rX   test_prangez"TestParforsDiagnostics.test_prange  sf    	 	 	 	

9&&y"55o&:;1=====rZ   c                     d }|                      |           |                     |d          }|j        d         }|                     t	          d |j        D                                  dS )zEmake sure original user variable name is used in fusion info
        c                     d} t          j        |           }t          j        |          }t          j        ||z            }d}t	          | dz
            D ].}t	          | dz
            D ]}|||         ||dz            z   z  }/|S )Nr  r   r   r   )r   r  sincosr   )r  r   r   r   r  r  r  s          rX   r	  z;TestParforsDiagnostics.test_user_varname.<locals>.test_impl  s    A

Aq		Aq1uACAE]] + +A + +A1Q4!AE(?*CC+JrZ   r~   r  c              3   (   K   | ]}d |j         v V  dS )zslice(0, n, 1)N)r  )r   r  s     rX   r  z;TestParforsDiagnostics.test_user_varname.<locals>.<genexpr>  s*      RR! AI-RRRRRRrZ   N)r   r   r  rO  anyfusion_reportsr  s       rX   test_user_varnamez(TestParforsDiagnostics.test_user_varname  s    		 		 		 	

9&&y"55o&:; 	RR{7QRRRRR	T 	T 	T 	T 	TrZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |dddgi           d S )Nc                      d} t          j        | | f          }t          |           D ]!}t          |           D ]}|dz  |z   |||f<   "|S r  r  )r  r   r  r  s       rX   r	  z<TestParforsDiagnostics.test_nested_prange.<locals>.test_impl  se    A!Q  AAYY ) ) ) )A"fqjAadGG)HrZ   r~   r  r   r   )r  r  r  r  s       rX   test_nested_prangez)TestParforsDiagnostics.test_nested_prange  s{    	 	 	 	

9&&y"55o&:;145s8 	  	= 	= 	= 	= 	=rZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |dddgidg           d S )	Nc                  Z    d} t          j        |           }t          j        |          }|S r  )r   r  r  r  s      rX   r	  zCTestParforsDiagnostics.test_function_replacement.<locals>.test_impl  s&    A

A	!AHrZ   r~   r  r   r   r  )r  r  )r  r  r  r  r  s       rX   test_function_replacementz0TestParforsDiagnostics.test_function_replacement  s    	 	 	 	

9&&y"55o&:;1-.H0C/E 	  	G 	G 	G 	G 	GrZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                  v    d} t          j        | dz             }d}t          |           D ]}|||         z  }|S r7  )r   r  r   )r  r   r  r  s       rX   r	  z8TestParforsDiagnostics.test_reduction.<locals>.test_impl  sF    AAACAYY  qtJrZ   r~   r  r   r  r  r  s       rX   r  z%TestParforsDiagnostics.test_reduction  sf    	 	 	 	

9&&y"55o&:;1=====rZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                  @    d} t          j        |           }d|d d <   |S )Nr  rZ  r  )r  r   s     rX   r	  z6TestParforsDiagnostics.test_setitem.<locals>.test_impl  s&    A

AAaaaDHrZ   r~   r  r   r  r  r  s       rX   test_setitemz#TestParforsDiagnostics.test_setitem  sf    	 	 	 	

9&&y"55o&:;1=====rZ   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                      d} d}d}t          |           D ]9}t          j        |f          }t          |          D ]}|||<   ||d         z  }:|S )Nr  r   r   rK   )r   r   r4  r  )r  rE  r  r  tempr  s         rX   r	  zBTestParforsDiagnostics.test_allocation_hoisting.<locals>.test_impl  si    AACAYY    x~~q    ADGGtBxJrZ   r~   r  r   )r  r  r  s       rX   test_allocation_hoistingz/TestParforsDiagnostics.test_allocation_hoisting  sf    		 		 		 	

9&&y"55o&:;CCCCCrZ   )NNNNN)ry   rP   rz   r   r}  r|  r  r  r  r  r  r  r  r  r  r~   rZ   rX   ry  ry  Y  s        M M M  
   =A@DBF$ $ $ $:; ; ;> > >T T T,= = =G G G> > >
> 
> 
>D D D D DrZ   ry  c                       e Zd Zd Zd ZdS )TestPrangeBasec                 ^   |j         }t          |j                  }|?d|j        v sJ t          d |j        D                       }t	          |j                  }n|j                            d          }g }t          j        |          D ]B}|j	        dk    r5t          |j                  |k    r|                    |j        dz              C|                    d           t          |          }t          |          dz
  }	t          j        dk    rd|	dz  z   }	t#          |j                  }t          |          t          |          k    sJ |D ]}
||
         }|	||<   t	          |          }|                    ||          }t'          j        |t+                                }|S )	z
        This function does the actual code augmentation to enable the explicit
        testing of `prange` calls in place of `range`.
        Nr  c                 "    g | ]}|d k    r|ndS )r  r   r~   r   s     rX   r   z7TestPrangeBase.generate_prange_func.<locals>.<listcomp>  s:     "A "A "A&' ()G||!! "A "A "ArZ   LOAD_GLOBALr   r   )r  r  )co_codeco_names)__code__r   r  r   bytesr  r  disBytecodeopnamerD   r  r   offsetr   rE   	PYVERSION	bytearrayreplacepytypesFunctionTypeglobals)rU   r   patch_instancepyfunc_codeprange_namesnew_code	range_idxrange_locationsinstr
prange_idxr  r  prange_codepfuncs                 rX   generate_prange_funcz#TestPrangeBase.generate_prange_func  s   
 oK011! k22222  "A "A+6+?"A "A "A B BL[011HH $,227;;I Ok22 A A<=00+EI66)CC'..u|a/?@@@))) ..L\**Q.J'))*/2
 !455H~&&#o*>*>>>>># + +%a( *XH "))(3? * A A $['))<<rZ   c                 f   |                     dd          }|                     dd          }|                     dd          }|                     ||          }t          d |D                       }|                     ||          }	t	          j        d          5 }
t	          j        d	           |                     ||          }ddd           n# 1 swxY w Y   |r|                     ||           |r%| 	                    ||          }t          d
|ifi |} | j        ||	|g|R i | |
S )a
  
        The `prange` tester
        This is a hack. It basically switches out range calls for prange.
        It does this by copying the live code object of a function
        containing 'range' then copying the .co_names and mutating it so
        that 'range' is replaced with 'prange'. It then creates a new code
        object containing the mutation and instantiates a function to contain
        it. At this point three results are created:
        1. The result of calling the original python function.
        2. The result of calling a njit compiled version of the original
            python function.
        3. The result of calling a njit(parallel=True) version of the mutated
           function containing `prange`.
        The three results are then compared and the `prange` based function's
        llvm_ir is inspected to ensure the scheduler code is present.

        Arguments:
         pyfunc - the python function to test
         args - data arguments to pass to the pyfunc under test

        Keyword Arguments:
         patch_instance - iterable containing which instances of `range` to
                          replace. If not present all instance of `range` are
                          replaced.
         scheduler_type - 'signed', 'unsigned' or None, default is None.
                           Supply in cases where the presence of a specific
                           scheduler is to be asserted.
         check_fastmath - if True then a check will be performed to ensure the
                          IR contains instructions labelled with 'fast'
         check_fastmath_result - if True then a check will be performed to
                                 ensure the result of running with fastmath
                                 on matches that of the pyfunc
         Remaining kwargs are passed to np.testing.assert_almost_equal


        Example:
            def foo():
                acc = 0
                for x in range(5):
                    for y in range(10):
                        acc +=1
                return acc

            # calling as
            prange_tester(foo)
            # will test code equivalent to
            # def foo():
            #     acc = 0
            #     for x in prange(5): # <- changed
            #         for y in prange(10): # <- changed
            #             acc +=1
            #     return acc

            # calling as
            prange_tester(foo, patch_instance=[1])
            # will test code equivalent to
            # def foo():
            #     acc = 0
            #     for x in range(5): # <- outer loop (0) unchanged
            #         for y in prange(10): # <- inner loop (1) changed
            #             acc +=1
            #     return acc

        r  Nr   Fcheck_fastmath_resultc                 6    g | ]}t          j        |          S r~   r   r   s     rX   r   z0TestPrangeBase.prange_tester.<locals>.<listcomp>  r   rZ   Tr  r  r   )r   r  r   r   r  r  r  r   rZ  r   r1  r   )rU   r   r   r   r  r   r  r  r   r   r  r   
fastcpfuncs                rX   prange_testerzTestPrangeBase.prange_tester=  s   B  $4d;;$4e<< &

+BE J J))&.AA 33d33344!!&#.. $D111 	7_!(+++**5#66F	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7
  	-  ,,, ! 	D77sCCJ+Z8CCFCCF$$VUFLTLLLVLLLs   +CCCN)ry   rP   rz   r  r  r~   rZ   rX   r  r  	  s8        0 0 0d\ \ \ \ \rZ   r  c                   
   e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd 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 Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd%S )&TestPrangeBasicz Tests Prange c                 <    d }|                      |dd           d S )Nc                  f    d} t          j        |           }t          |           D ]
}d|z  ||<   |S )Nr  r  r   r4  r  r  s      rX   r	  z0TestPrangeBasic.test_prange01.<locals>.test_impl  s=    AA1XX  Qw!HrZ   r   Tr   r   r  r  s     rX   test_prange01zTestPrangeBasic.test_prange01  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                  t    d} t          j        | dz
            }t          d|           D ]}d|z  ||dz
  <   |S )Nr  r   r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange02.<locals>.test_impl  sG    AQA1a[[ # #7!a%HrZ   r   Tr  r  r  s     rX   test_prange02zTestPrangeBasic.test_prange02  r  rZ   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S Nr  r   r  r  r  s     rX   r	  z0TestPrangeBasic.test_prange03.<locals>.test_impl  ,    A2YY  QHrZ   r   Tr  r  r  s     rX   test_prange03zTestPrangeBasic.test_prange03  A    	 	 	
 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r  r   r  r  s     rX   r	  z3TestPrangeBasic.test_prange03mul.<locals>.test_impl  s,    A2YY  QHrZ   r   Tr  r  r  s     rX   test_prange03mulz TestPrangeBasic.test_prange03mul  r  rZ   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r  r   r  r  s     rX   r	  z3TestPrangeBasic.test_prange03sub.<locals>.test_impl  s,    A2YY  QHrZ   r   Tr  r  r  s     rX   test_prange03subz TestPrangeBasic.test_prange03sub  r  rZ   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S r  r  r  s     rX   r	  z3TestPrangeBasic.test_prange03div.<locals>.test_impl  r  rZ   r   Tr  r  r  s     rX   test_prange03divz TestPrangeBasic.test_prange03div  r  rZ   c                 <    d }|                      |dd           d S )Nc                  |    d} d}t          j        d          }t          d          D ]}|| k    r|||<   d||<   |S )Nr   r  r  r   r   r  r  r   r   r  r  s       rX   r	  z0TestPrangeBasic.test_prange04.<locals>.test_impl  sR    AAA1XX  66AaDDAaDDHrZ   r   Tr  r  r  s     rX   test_prange04zTestPrangeBasic.test_prange04  sA    		 		 		 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          d| dz
  d          D ]}|||         z  }|S Nr  r&  r   r   r   r  r  r  r  r  r  r  s       rX   r	  z0TestPrangeBasic.test_prange05.<locals>.test_impl  sU    A2:...AA1a!eQ''  QqT	HrZ   r   Tr  r  r  s     rX   test_prange05zTestPrangeBasic.test_prange05  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          ddd          D ]}|||         z  }|S r  r  r  s       rX   r	  z0TestPrangeBasic.test_prange06.<locals>.test_impl  sO    A2:...AA1a^^  QqT	HrZ   r   Tr  r  r  s     rX   test_prange06zTestPrangeBasic.test_prange06  r  rZ   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          | d          D ]}|||         z  }|S r  r  r  s       rX   r	  z0TestPrangeBasic.test_prange07.<locals>.test_impl  sM    A2:...AA1a[[  QqT	HrZ   r   Tr  r  r  s     rX   test_prange07zTestPrangeBasic.test_prange07  r  rZ   c                 <    d }|                      |dd           d S )Nc                      d} t          j        |           }d}t          t          |                    D ],}t          t          |                    D ]}|||         z  }-|S rk  r   r  r  r   r  r  r  r  r  s        rX   r	  z0TestPrangeBasic.test_prange08.<locals>.test_impl  sh    AAC3q66]]    s1vv    A1Q4KCC JrZ   r   Tr  r  r  s     rX   test_prange08zTestPrangeBasic.test_prange08  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                      d} t          j        |           }d}t          d          D ]}t          d          D ]}|||         z  } |S rk  r   r  r  r  s        rX   r	  z2TestPrangeBasic.test_prange08_1.<locals>.test_impl  s\    AAC1XX    q    A1Q4KCC JrZ   r   Tr  r  r  s     rX   test_prange08_1zTestPrangeBasic.test_prange08_1  r
  rZ   c                 @    d }|                      |dgdd           d S )Nc                  `    d} d}t          |           D ]}t          |           D ]}|dz  }|S Nr  r   r   r  )r  r  r  r  s       rX   r	  z0TestPrangeBasic.test_prange09.<locals>.test_impl   sK    AC1XX  q  A1HCCJrZ   r   r   Tr  r   r   r  r  s     rX   test_prange09zTestPrangeBasic.test_prange09  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rZ   c                 @    d }|                      |dgdd           d S )Nc                  n    d} d}t          |           D ] }d}t          |           D ]}|dz  }||z  }!|S r  r  )r  acc2r  acc1r  s        rX   r	  z0TestPrangeBasic.test_prange10.<locals>.test_impl-  sV    AD1XX  q  AAIDDKrZ   r   r   Tr  r  r  s     rX   test_prange10zTestPrangeBasic.test_prange10,  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rZ   z1list append is not thread-safe yet (#2391, #2408)c                 <    d }|                      |dd           d S )Nc                  8    d} d t          |           D             S )Nr  c                 6    g | ]}t          j        |          S r~   )r   r  )r   r  s     rX   r   zDTestPrangeBasic.test_prange11.<locals>.test_impl.<locals>.<listcomp>?  s     000!BF1II000rZ   r  r  s    rX   r	  z0TestPrangeBasic.test_prange11.<locals>.test_impl=  s!    A00uQxx0000rZ   r   Tr  r  r  s     rX   test_prange11zTestPrangeBasic.test_prange11;  sA    	1 	1 	1 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 <    d }|                      |dd           d S )Nc                      d} d}t          j        |          }t          t          |                     D ]}| ||         z  } | S r  r  )r  r  rv  r  s       rX   r	  z0TestPrangeBasic.test_prange12.<locals>.test_implD  sJ    CA

ACFF7^^  qtJrZ   r   Tr  r  r  s     rX   test_prange12zTestPrangeBasic.test_prange12C  sA    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rZ   c                 b    d }|                      |t          j        d          dd           d S )Nc                 8    d}t          |           D ]}|dz  }|S r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange13.<locals>.test_implO  s,    C1XX  qJrZ   r  r   Tr  )r  r   r  r  s     rX   test_prange13zTestPrangeBasic.test_prange13N  sK    	 	 	
 	9bhqkk**. 	 	0 	0 	0 	0 	0rZ   c                 x    d }|                      |t          j                            d          dd           d S )Nc                 d    d}t          t          |                     D ]}|| |         dz  z  }|S )Nr  r   r  r   )r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange14.<locals>.test_implX  s:    A3q66]]  QqT!VHrZ   r  r   Tr  )r  r   r  r  r  s     rX   test_prange14zTestPrangeBasic.test_prange14W  sR    	 	 	 	9binnQ&7&7*4*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                 l    d}t          |           D ]!}t          j        d          }||d         z  }"|S )Nr   r0  r4  )r  r   r  )r  r  r  r   s       rX   r	  z0TestPrangeBasic.test_prange15.<locals>.test_implg  s=    C1XX  GFOOqwJrZ   r  r   Tr  r  r  s     rX   test_prange15zTestPrangeBasic.test_prange15d  sC    	 	 	 	9d:*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                 <    d}t          |  |           D ]}|dz  }|S r  r  r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange16.<locals>.test_implr  s0    CA2q\\  qJrZ   r  r   Tr  r  r  s     rX   test_prange16zTestPrangeBasic.test_prange16q  sC    	 	 	
 	9d8*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                 p    d}t          j        |           }t          |  |           D ]}|||         z  }|S r  r  r  r  rv  r  s       rX   r	  z0TestPrangeBasic.test_prange17.<locals>.test_impl{  sA    C

AA2q\\  qtJrZ   r  r   Tr  r  r  s     rX   test_prange17zTestPrangeBasic.test_prange17z  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                     d}t          j        |           }t          |  d          D ]+}|||         z  }t          d|           D ]}|||         z  },|S )Nr   r   r  )r  r  rv  r  r  s        rX   r	  z0TestPrangeBasic.test_prange18.<locals>.test_impl  sj    C

AA2q\\    qtr1    A1Q4KCC JrZ   r  r   Tr  r  r  s     rX   test_prange18zTestPrangeBasic.test_prange18  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                     d}| dz   }t          j        | |f          }t          |  |           D ]#}t          | |          D ]}||||f         z  }$|S r  r  )r  r  Mrv  r  r  s         rX   r	  z0TestPrangeBasic.test_prange19.<locals>.test_impl  sp    CAAAAA2q\\ # #r1 # #A1QT7NCC#JrZ   r  r   Tr  r  r  s     rX   test_prange19zTestPrangeBasic.test_prange19  r7  rZ   c                 >    d }|                      |ddd           d S )Nc                 n    d}t          j        |           }t          d|           D ]}|||         z  }|S )Nr   rK   r  r0  s       rX   r	  z0TestPrangeBasic.test_prange20.<locals>.test_impl  s?    C

A2q\\  qtJrZ   r  r   Tr  r  r  s     rX   test_prange20zTestPrangeBasic.test_prange20  r2  rZ   c                 >    d }|                      |ddd           d S )Nc                 :    d}t          dd          D ]}|dz  }|S )Nr   r0  rK   r  r  r,  s      rX   r	  z0TestPrangeBasic.test_prange21.<locals>.test_impl  s.    C2r]]  qJrZ   r  r   Tr  r  r  s     rX   test_prange21zTestPrangeBasic.test_prange21  sC    	 	 	
 	9a*. 	 	0 	0 	0 	0 	0rZ   c                 >    d }|                      |ddd           d S )Nc                      d} d}t          j        d          }t          dd          D ]}|| k    r|||<   |dk     rd||<   d||<    |S )	Nr   r  r  r(  r   r   rK   rZ  r  r  s       rX   r	  z0TestPrangeBasic.test_prange22.<locals>.test_impl  sh    AAA2q\\  66AaDDUUAaDDAaDDHrZ   r   Tr   r   r  r  r  s     rX   test_prange22zTestPrangeBasic.test_prange22  sH    	 	 	 	9X*.d 	 	L 	L 	L 	L 	LrZ   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 N    t          t          |                     D ]}|| |<   | S r\   r%  r  r  s     rX   r	  z0TestPrangeBasic.test_prange23.<locals>.test_impl  s-    3q66]]  !HrZ       r   r   TrD  r   r4  r  rU   r	  r  s      rX   test_prange23zTestPrangeBasic.test_prange23  sb    	 	 	 HRLL19a
*.d 	 	L 	L 	L 	L 	LrZ   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 R    t          t          |            d          D ]}|| |<   | S r  r%  rH  s     rX   r	  z0TestPrangeBasic.test_prange24.<locals>.test_impl  s3    CFF7A&&  !HrZ   rI  r   r   TrD  rJ  rK  s      rX   test_prange24zTestPrangeBasic.test_prange24  sb    	 	 	 HRLL19a*.d 	 	L 	L 	L 	L 	LrZ   c                 F   d }t          j        d          }|                     ||dgddd           |                     |t	          j        |          f          }|j        d         }|                                }|                     t          |          d           d S )	Nc                      t                     } fdt          |          D             }t          |          D ]
} |z   ||<   |S )Nc                 8    g | ]}t          j                  S r~   )r   
zeros_like)r   rL   r  s     rX   r   zDTestPrangeBasic.test_prange25.<locals>.test_impl.<locals>.<listcomp>  s#    6662=##666rZ   )r   r  )r  r  rq  r  s   `   rX   r	  z0TestPrangeBasic.test_prange25.<locals>.test_impl  sV    AA6666U1XX666C1XX  QAJrZ   r  r   r   T)r  r   r   r  r  r   )
r   r  r  r   r   r   r  r  r   r   )rU   r	  r  r   r  r  s         rX   test_prange25zTestPrangeBasic.test_prange25  s    	 	 	 GENN9a!*4T15 	 	7 	7 	7 &&y5<??2DEEo&:;$88::^,,a00000rZ   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 d    | d d d         }t          t          |                    D ]}|||<   | S rp  r%  )r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange26.<locals>.test_impl  s<    ##A#A3q66]]  !HrZ   rI  r   r   TrD  rJ  rK  s      rX   test_prange26zTestPrangeBasic.test_prange26  sb    	 	 	
 HRLL19a
*.d 	 	L 	L 	L 	L 	LrZ   c           	          d }|                      |t          j        d          t          j        g d          ddgdd           d S )	Nc                     t          |d         dz
            D ]6}t          d          D ]$}t          j        | |dz
  |dz                      }%7dS r   )r  r   abs)r   r   r  r  r   rB  s         rX   r	  z0TestPrangeBasic.test_prange27.<locals>.test_impl  s_    1Q46]] + +q + +Aq1QqSz**AA+1rZ   rC  )
r  r  r  r  r  r  r  r  r  r  r   r   r   Tr  )r  r   r  asarrayr  s     rX   test_prange27zTestPrangeBasic.test_prange27  si    	 	 	 	99R==:&;&;&;<<+,#*4*. 	 	0 	0 	0 	0 	0rZ   c           	          d }t          j        ddgddgddgddgddgddgg          }t          j        ddgddgddgdd	gd	d
gg          }|                     |||ddd           d S )Nc                    t          j        t          |                    }t          dt          |                    D ]A}||df         }||df         }| |         }| |         }||z
  }|d         |d         z   }	|	||<   B|S r  )r   r4  r   r  )
r   rl  r  r  i0i1Pt1Pt2r  vl2s
             rX   r	  z0TestPrangeBasic.test_prange28.<locals>.test_impl  s    (3q66""CQA''  sAvYsAvYee#IdQqTkCJrZ         r_  r  r   r   r   r  r  r   r   TrD  )r   r  r  rM  s       rX   test_prange28zTestPrangeBasic.test_prange28  s    
	 
	 
	 HsCjRjRjCjRjRj" # # Hq!f!f!f!f!f	   	9a:*.d 	 	L 	L 	L 	L 	LrZ   c                 d    d }|                      |d           |                      |d           d S )Nc                 l    d}| rt          d          D ]}|dz  }nt          d          D ]}|dz  }|S )Nr   r   r  r  )r  r  r  s      rX   r	  z0TestPrangeBasic.test_prange29.<locals>.test_impl  s[    F  q    AaKFF  q    AaKFFMrZ   TFr  r  s     rX   test_prange29zTestPrangeBasic.test_prange29  sE    	 	 	 	9d+++9e,,,,,rZ   c                     d }t          j        t          j        ddd                    }t          j        g d          }|                     |||d           d S )Nc                 ,   |j         d         }t          |           }t          j        ||ft          j                  }t          |           |z   dz
  |z  }t          |          D ]-}||z  }|dz   |z  }	| ||	         |d d          z  |d d ||	f<   .|S r  )r  r   r   r4  r  r  )
r   par
numthreadsn_parn_xr  chunklenr  r  r  s
             rX   r	  z0TestPrangeBasic.test_prange30.<locals>.test_impl.  s    IaLEa&&CXucl"*===FA+a/J>H:&& ? ?HA)()%*AAA(>qqq%*}%%MrZ   r   r  r_  r  r   )r   r  r  r  )rU   r	  r   rk  s       rX   test_prange30zTestPrangeBasic.test_prange30,  sc    	 	 	 HRYq!S))**h''9aa00000rZ   N)(ry   rP   rz   r[  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  ri  skipr  r  r"  r&  r)  r-  r1  r6  r;  r>  rA  rE  rL  rO  rT  rW  r\  re  rh  rp  r~   rZ   rX   r  r    sB       0 0 00 0 00 0 00 0 00 0 00 0 00 0 0	0 	0 	0	0 	0 	0	0 	0 	0
0 
0 
0
0 
0 
00 0 00 0 0 X]FGG0 0 HG0	0 	0 	00 0 00 0 0
0 
0 
00 0 00 0 0
0 
0 
0
0 
0 
00 0 00 0 0L L L L L LL L L1 1 1"L L L0 0 0"L L L<- - -1 1 1 1 1rZ   r  c                       e Zd ZdZd Zd Zd Zd Zed             Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zed             ZdS )TestPrangeSpecificz4 Tests specific features/problems found under prangec                 8    d }|                      |d           d S )Nc                 N    d}t          |           D ]}|dz  }|dk    r|dz  }|S Nr   r   r  r  r  r  r  s      rX   r	  zRTestPrangeSpecific.test_prange_two_instances_same_reduction_var.<locals>.test_implG  =    A1XX  Qr66FAHrZ   r  r  r  s     rX   ,test_prange_two_instances_same_reduction_varz?TestPrangeSpecific.test_prange_two_instances_same_reduction_varE  s/    	 	 	 	9a(((((rZ   c                     d }|                      t          j                  5 }|                     |d           d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )Nc                 N    d}t          |           D ]}|dz  }|dk    r|dz  }|S rv  r  rw  s      rX   r	  zKTestPrangeSpecific.test_prange_conflicting_reduction_ops.<locals>.test_implQ  rx  rZ   r  zBReduction variable c has multiple conflicting reduction operators.)r  r   UnsupportedErrorr  r   r#  r  rU   r	  r  r   s       rX   %test_prange_conflicting_reduction_opsz8TestPrangeSpecific.test_prange_conflicting_reduction_opsP  s    	 	 	 v677 	-6y!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-c3v/0011111   AA
A
c                 6    d }|                      |           d S )Nc                      dx} }t          d          D ]/}|dk    r| dz  } t          j        d          }|d         r|dz  }0| |fS )Nr   r   r   r0  r4  r  )r  r  r   r   s       rX   r	  zLTestPrangeSpecific.test_prange_two_conditional_reductions.<locals>.test_impla  sb    IA1XX  66FAA((Aw Qa4KrZ   r  r  s     rX   &test_prange_two_conditional_reductionsz9TestPrangeSpecific.test_prange_two_conditional_reductions_  s-    		 		 		 	9%%%%%rZ   c                 6    d }|                      |           d S )Nc                  h    d} t          d          D ]}t          d          D ]}|dk    r| dz  }  | S r  r  )r  r   r  s      rX   r	  zCTestPrangeSpecific.test_prange_nested_reduction1.<locals>.test_impln  sP    A1XX  q  AAvvQ HrZ   r  r  s     rX   test_prange_nested_reduction1z0TestPrangeSpecific.test_prange_nested_reduction1m  s-    	 	 	 	9%%%%%rZ   c                    d }|                      t                    5 } |             d d d            n# 1 swxY w Y   |                     |d           }|                     |d          }|                     |d          }|                      t                    5 }|                                 d d d            n# 1 swxY w Y   |                                }|                     |d         t          j                   d S )Nc                  f    d} t          j        |           }t          |           D ]
}d|z  ||<   |S )NrI  r   r  r  s      rX   r	  z<TestPrangeSpecific.test_check_error_model.<locals>.test_imply  s=    AA1XX  1u!HrZ   r~   r   )	r  ZeroDivisionErrorr  r   r   r   r   r   r  )rU   r	  r  r  pcrespfcresr  s          rX   test_check_error_modelz)TestPrangeSpecific.test_check_error_modelw  sv   	 	 	 011 	VIKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 )))T::%%eR00//r:: 011 	 V	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ##%%BF+++++s   599B==CCc                    d }t          j        d                              dd          }|                     ||ddd           |                     |d           }t          t          j        |          g          }|                     ||          }| 	                    |          }|
                                D ]O\  }}|                                D ]5}	d|	v r/||	v r+|                     |	                    d	          d
            n6Pd S )Nc                 b    t          t          |                     D ]}| |         }d|d d <   | S r"  r%  )r  r  r  s      rX   r	  z?TestPrangeSpecific.test_check_alias_analysis.<locals>.test_impl  s:    3q66]]  aD!!!HrZ   rI  r  r8  r   TrD  definenoaliasr   )r   r4  r  r  r  r   r   r   r   r6  rW  r@  r   rS  )
rU   r	  r  r  r   r   rX  r   r  r  s
             rX   test_check_alias_analysisz,TestPrangeSpecific.test_check_alias_analysis  s*   	 	 	
 HRLL  A&&9a
*.d 	 	L 	L 	L)))T::U\!__%&&--eS99!!$''IIKK 	 	DAq  t##T		 $$TZZ	%:%:A>>>E	 	rZ   c                     d }|                      t          j                  5 }|                     |d           d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )Nc                 <    d}t          d| d          D ]}|dz  }|S r  r  r,  s      rX   r	  zJTestPrangeSpecific.test_prange_raises_invalid_step_size.<locals>.test_impl  s0    C1a^^  qJrZ   r  z4Only constant step size of 1 is supported for prange)r  r   rT  r  r   r#  r  r}  s       rX   $test_prange_raises_invalid_step_sizez7TestPrangeSpecific.test_prange_raises_invalid_step_size  s    	 	 	 v=>> 	0&y$///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0Dc3v/0011111r  c                 >   d }|                      |dd           |                     |d           }|                     |d          }|                     |          }d}d}t	          j        |||fz            }t	          j        d|d	|d
|          } |j                    D ]v\  }	}
|
                                }t          |          D ]\  }}|	                    |          r n| 
                    |	                    ||dz                                 wd S )Nc                  B    d} d}t          |           D ]
}||dz  z  }|S )Nr  r   r  r  r  s      rX   r	  zFTestPrangeSpecific.test_prange_fastmath_check_works.<locals>.test_impl  s5    AA1XX  QWHrZ   r   Tr  r~   z%[A-Z_0-9]?(.[0-9]+)+[.]?[i]?z)\s+%s = fmul fast double %s, 5.000000e-01z\s+z = fadd fast double z, r   )r  r  r   r6  rA  compilerW  r@  r  rU  rO  )rU   r	  r  r   r   _id
recipr_strreciprocal_inst	fadd_instr!  kernelrC  r  r   s                 rX    test_prange_fastmath_check_worksz3TestPrangeSpecific.test_prange_fastmath_check_works  s[   	 	 	 	9Z*. 	 	0 	0 	0)))T::--eR88  &&-@
*Z3*%<==JJ"%##sssCC 1 2 2	
 %BHJJ 	> 	>LD&((**H!(++  1"((++ EOOIOOHQUO<<====	> 	>rZ   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }|d         }t          |           D ]
}|dz   ||<   |                                S r  r   r4  r  r~  )r  r   r   r  s       rX   r	  z8TestPrangeSpecific.test_parfor_alias1.<locals>.test_impl  sO    !Q  A!A1XX  1u!5577NrZ   r  r  r  s     rX   test_parfor_alias1z%TestPrangeSpecific.test_parfor_alias1  s/    	 	 	 	9a(((((rZ   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }t          |           D ]$}||         }t          |           D ]
}||z   ||<   %|                                S r\   r  )r  r   r  r   r  s        rX   r	  z8TestPrangeSpecific.test_parfor_alias2.<locals>.test_impl  si    !Q  A1XX  A$aQxx  !1u!5577NrZ   r  r  r  s     rX   test_parfor_alias2z%TestPrangeSpecific.test_parfor_alias2  s/    	 	 	 	9a(((((rZ   c                 8    d }|                      |d           d S )Nc                     t          j        | | | f          }t          |           D ]A}||         }t          |           D ]'}||         }t          |           D ]}||z   |z   ||<   (B|                                S r\   r  )r  r   r  r   r  r  r   s          rX   r	  z8TestPrangeSpecific.test_parfor_alias3.<locals>.test_impl  s    !Q##A1XX # #A$aQxx # #!aDq # #AQ!A$$## 5577NrZ   r  r  r  s     rX   test_parfor_alias3z%TestPrangeSpecific.test_parfor_alias3  s/    	 	 	 	9a(((((rZ   c                     d }|                      |dd          }|d         }d}|                     |t          |j                             d S )Nc                 .    t          |          D ]}| }|S r\   r  )r   rl  r  r   s       rX   r	  z8TestPrangeSpecific.test_parfor_race_1.<locals>.test_impl  s#    1XX  HrZ   r  rC  r   zVariable k used in parallel loop may be written to simultaneously by multiple workers and may result in non-deterministic or unintended results.)r  r   r#  r  )rU   r	  r  warning_objexpected_msgs        rX   test_parfor_race_1z%TestPrangeSpecific.test_parfor_race_1  sc    	 	 	 ,,YB??%a(F 	lC(;$<$<=====rZ   c                 6    d }|                      |           dS )a   issue 3686: if a prange has something inside it that causes
            a nested parfor to be generated and both the inner and outer
            parfor use the same call variable defined outside the parfors
            then ensure that when that call variable is pushed into the
            parfor that the call variable isn't duplicated with the same
            name resulting in a redundant type lock.
        c                  .   d} t           j        }t          d          D ]3} |d          }|  |t          j        d                    d         z  } 4t          d          D ]3} |d          }|  |t          j        d                    d         z  } 4| S )Nr   r   r_  r   )r   negativer  r4  )r  r  r  this_matterss       rX   r	  zGTestPrangeSpecific.test_nested_parfor_push_call_vars.<locals>.test_impl  s    AA1XX ( ( quuQQrx||__Q''1XX ( ( quuQQrx||__Q''HrZ   Nr  r  s     rX   !test_nested_parfor_push_call_varsz4TestPrangeSpecific.test_nested_parfor_push_call_vars  s-    
	 
	 
	 	9%%%%%rZ   c                     d }d}t          j        |||f          }t          j        |t           j                  }|                     |||dg           dS )a+   issue4903: a global is copied next to a parfor so that
            it can be inlined into the parfor and thus not have to be
            passed to the parfor (i.e., an unsupported function type).
            This global needs to be renamed in the block into which
            it is copied.
        c                    t          j        t          |                    }t          j        t          |                    }t          d          D ]l}||         }t          |          D ]!}|t          j        | ||f                   z  }"t          |          D ]!}|t          j        | ||f                   z  }"m||fS r"  )r   r4  r   r  ra  )zztclhlcr  ntr  s          rX   r	  zATestPrangeSpecific.test_copy_global_for_parfor.<locals>.test_impl  s    #b''""B#b''""B1XX + +Ur + +A"&AqD***BBr + +A"&AqD***BB+r6MrZ   r   r&  r   )r  N)r   r  r  r  )rU   r	  rE  r  r  s        rX   test_copy_global_for_parforz.TestPrangeSpecific.test_copy_global_for_parfor  sh    		 		 		 WaAYWQbg&&&9b"aSAAAAArZ   c                 8    d }|                      |d           d S )Nc                 x    d}t           j        }t          d          D ]} |d          }| ||           z  }|S )Nr   r   r_  )r   r  r  )r  r  r  r  r  s        rX   r	  zGTestPrangeSpecific.test_multiple_call_getattr_object.<locals>.test_impl*  sH    AA1XX   qvvQQqTT	HrZ   r_  r  r  s     rX   !test_multiple_call_getattr_objectz4TestPrangeSpecific.test_multiple_call_getattr_object)  s/    	 	 	 	9c*****rZ   c                    d }t          j        ddt          fdt          fg          }t          j        ddt          fdt          fg          }t          j        ddt          fdt          fg          }|                    t           j                  }|                    t           j                  }|                    t           j                  }t           ||                    }t           t          |          |                    }	t          |d          }
t           |
|                    }|                     ||	           |                     ||           d S )Nc                 X    t          t          |                     D ]}d| j        |<   | S r-  )r  r   r   )r  r  s     rX   r	  zHTestPrangeSpecific.test_argument_alias_recarray_field.<locals>.test_impl6  s/    3q66]]  AHrZ   r  r   rl  r&  TrP  )	r   r4  r.  rK  viewrecarrayr   r   r   )rU   r	  X1X2X3rH  rI  v3
python_resnjit_respa_funcpa_ress               rX   "test_argument_alias_recarray_fieldz5TestPrangeSpecific.test_argument_alias_recarray_field4  s<   	 	 	 Xb#uSz <===Xb#uSz <===Xb#uSz <===WWR[!!WWR[!!WWR[!! ))B--((
Y++,,y4000ggbkk""X...V,,,,,rZ   c                    t           d             fd} |d          } t          |          d          }t          |d          } |d          }|                     ||           |                     ||           dS )z issue3699: test that mutable variable to call in loop
            is not hoisted.  The call in test_impl forces a manual
            check here rather than using prange_tester.
        c                 V    | d         }| d         dz   }|                      |           |S )z If the variable X is hoisted in the test_impl prange
                then subsequent list_check calls would return increasing
                values.
            rK   r   )r   )rv  r  r   s      rX   
list_checkz>TestPrangeSpecific.test_mutable_list_param.<locals>.list_checkO  s.     B%C"	AHHQKKKJrZ   c                 H    t          |           D ]}dg} |          }|S r  r  )r  r  rv  r   r  s       rX   r	  z=TestPrangeSpecific.test_mutable_list_param.<locals>.test_implY  s3    AYY " "EJqMMHrZ   r  TrP  Nr   r   )rU   r	  r  r  r  r  r  s         @rX   test_mutable_list_paramz*TestPrangeSpecific.test_mutable_list_paramJ  s    
 
	 	 
		 	 	 	 	
 Yr]]
"4	??2&&y4000X...V,,,,,rZ   c                     d }t          j        g dt                    t          j        ddgt                    g}|                     ||           d S )Nc                 x     t          j         fdt          t                               D                       S )Nc                 :    g | ]}t          |                   S r~   )r   )r   r  r   s     rX   r   zXTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_impl.<locals>.<listcomp>h  s#    >>>1S1YY>>>rZ   )r   r  r  r   r1  s   `rX   r	  zDTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_implg  s4    8>>>>c!ff>>>???rZ   )r   r   r  r&  r   r   )r   r  rK  r  r)  s      rX   test_list_comprehension_prangez1TestPrangeSpecific.test_list_comprehension_prangee  s`    	@ 	@ 	@XgggS)))"(Aa5*D*D*DE9a(((((rZ   c                 |    d }t          j        dt           j                  }|                     ||dd           d S )Nc                     t          j        | j                  }t          | j        d                   D ]+}| |         d         dz  }|dk    rd}|dk    rd}|||g||<   ,|S )Nr   g     o@)r   r4  r  r  )imager   r   r  r  r  hs          rX   r	  z>TestPrangeSpecific.test_ssa_false_reduction.<locals>.test_implr  st    HU[))E5;q>** % %!HQK%'66A66Aq!9aLrZ   r_  r&  r   )r   r4  r  r  )rU   r	  r  s      rX   test_ssa_false_reductionz+TestPrangeSpecific.test_ssa_false_reductionl  sI    		 		 		 rx0009eQ22222rZ   c                 6    d }|                      |           d S )Nc                      d} t          j        | t           j                  }t          d          D ]}dg}d|d<   |d         ||<   |S )Nr   r&  r   r   )r   r  r  r  )r  r   r   rv  s       rX   r	  z@TestPrangeSpecific.test_list_setitem_hoisting.<locals>.test_impl  sV    A"(+++A1XX  C!t!HrZ   r  r  s     rX   test_list_setitem_hoistingz-TestPrangeSpecific.test_list_setitem_hoisting  s-    	 	 	 	9%%%%%rZ   c                     t          j        dt           j        fg          }d }d }|                     |t          j        d|          |g           d S )Nr  c                 @    t          d          D ]}d| |         d<   d S )Nr   r  r  )statesr  s     rX   r	  z?TestPrangeSpecific.test_record_array_setitem.<locals>.test_impl  s2    1XX % %#$q	%  % %rZ   c                 F    | d         d         |d         d         k    sJ d S )Nr   r  r~   r   s     rX   r  z>TestPrangeSpecific.test_record_array_setitem.<locals>.comparer  s)    Q4;!A$u+------rZ   r   )r  r'  r  )r   r'  r  r  r4  )rU   state_dtyper	  r  s       rX   test_record_array_setitemz,TestPrangeSpecific.test_record_array_setitem  s{    h 1233	% 	% 	%	/ 	/ 	/ 	98!;???/7j 	 	: 	: 	: 	: 	:rZ   c                     t          j        dt           j        fg          }d }t          j        d|          }d }|                     |||g           d S )Nr   c                 ^    | j         }t          | j                   D ]}d|z   | d         |<   | S )NrZ  r   )r  r  )r  r  r  s      rX   r	  zKTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.test_impl  s:    A6;'' ' '!"QsAMrZ   r  r&  c                 F    t           j                            | |           d S r\   r  r   s     rX   r  zJTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.comparer  r  rZ   r  )r   r'  r  r4  r  )rU   r  r	  r  r  s        rX   %test_record_array_setitem_yield_arrayz8TestPrangeSpecific.test_record_array_setitem_yield_array  s    hbg/00	 	 	 "K000	* 	* 	* 	9!/7j 	 	: 	: 	: 	: 	:rZ   c                 :    d }|                      |dd           d S )Nc                     t          j        | f          }|dk    r#t          |           D ]}||xx         dz  cc<   n"t          |           D ]}||xx         dz  cc<   |d         S )Nr   r   r   r  )r  caser  r  s       rX   r	  z4TestPrangeSpecific.test_issue7501.<locals>.test_impl  s    Xtg&&Fqyyt # #A1IIINIIII# t # #A1IIINIIII!9rZ   r  r   r  r  s     rX   test_issue7501z!TestPrangeSpecific.test_issue7501  s1    	 	 	 	9a+++++rZ   c                 z    d }d}t           j                            |          }|                     ||           d S )Nc                    d}t          j        g d          }|j        d         }| j        d         }d}t          |          D ]}| |         }||z
  dz   d|dz  z  z  }t          j        |          }	||	t          j        ||z            z
  t          j        t          j        t          j        ||	z
                                z   z  }|S )Nr^  )rd  r  rE  r   r   )r   r  r  r  r  r`  r~  ra  )
rv  r   pointsr  r  expsr  pr  rE  s
             rX   r	  z6TestPrangeSpecific.test_kde_example.<locals>.test_impl  s    AX...//FQA
AD1XX J JaD6zAo%!ad(3F1IIBF1q5MM)BF26"&Q--3H3H,I,IIIKrZ   r  )r   r  r  r  )rU   r	  r  rv  s       rX   test_kde_examplez#TestPrangeSpecific.test_kde_example  sG    	 	 	 INN19a(((((rZ   c                     t          j        t          j        ddgdt           j                  }|                     d|                                           d S )Nz-mz#numba.tests.parfors_max_label_errorr  )rO   stderrzTEST PASSED)subpcheck_outputsys
executableSTDOUTr   decode)rU   r  s     rX   test_issue_due_to_max_labelz.TestPrangeSpecific.test_issue_due_to_max_label  sT     ^T#HI;
 
 

 	mSZZ\\22222rZ   N)ry   rP   rz   r[  ry  r~  r  r  r@   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r<   r  r~   rZ   rX   rs  rs  A  s       >>	) 	) 	)2 2 2& & && & & , , ],0  0
2 
2 
2> > ><) ) )) ) )
) 
) 
)
> 
> 
>& & &*B B B.	+ 	+ 	+- - -,- - -6) ) )3 3 3(& & &: : :: : :$, , ,) ) )& 3 3 3 3 3rZ   rs  c                   X    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )TestParforChunksizingz:
    Tests chunksize handling in ParallelAccelerator.
    Fc                 $    t          d           d S r  r   r^   s    rX   setUpzTestParforChunksizing.setUp      q!!!!!rZ   c                 $    t          d           d S r  r  r^   s    rX   tearDownzTestParforChunksizing.tearDown  r  rZ   c                    |                      t                      d           t          d           |                      t                      d           t          d           |                      t                      d           d S Nr   r8  )r   r   r   r^   s    rX   $test_python_parallel_chunksize_basicz:TestParforChunksizing.test_python_parallel_chunksize_basic  s{    /111555q!!!/111555q!!!/11155555rZ   c                     |                      t                      d           t          d          5  |                      t                      d           d d d            n# 1 swxY w Y   |                      t                      d           d S r  )r   r   r   r^   s    rX   test_python_with_chunksizez0TestParforChunksizing.test_python_with_chunksize  s    /111555"" 	: 	:355q999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:/11155555s   #A!!A%(A%c                 &   t           d             }t           d             }|                      |            d            |d           |                      |            d            |d           |                      |            d           d S )Nc                      t                      S r\   )r   r~   rZ   rX   get_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.get_cs  s    )+++rZ   c                      t          |           S r\   r  r1  s    rX   set_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.set_cs  s    )!,,,rZ   r   r8  r  )rU   r  r	  s      rX   "test_njit_parallel_chunksize_basicz8TestParforChunksizing.test_njit_parallel_chunksize_basic  s    		, 	, 
	, 
	- 	- 
	- 	1%%%q			1%%%q			1%%%%%rZ   c                     t           d             } |d          \  }}}|                     |d           |                     |d           |                     |d           d S )Nc                     t                      }t          d          5  t                      }d d d            n# 1 swxY w Y   t                      }|||fS )Nr8  )r   r   )r   cs1cs2cs3s       rX   r	  zATestParforChunksizing.test_njit_with_chunksize.<locals>.test_impl	  s    (**C#A&& / /,../ / / / / / / / / / / / / / /(**CS= s   9= =r8  r   r  )rU   r	  r  r  r  s        rX   test_njit_with_chunksizez.TestParforChunksizing.test_njit_with_chunksize  sx    		! 	! 
	! "	!S#a   a   a     rZ   c                 6   t          d          d             }dD ]|}t          d          D ]j} ||dz   |          \  }}|                     t          j        |dk                         |                     t          j        |dk                         k}d	S )
z Test that all the iterations get run if you set the
            chunksize.  Also check that the chunksize that each
            worker thread sees has been reset to 0. TrP  c                    t          j        |          }t          j        |d          }t          j        |           5  t          j        |          D ]}t          j                    ||<   d||<   	 d d d            n# 1 swxY w Y   ||fS )Nir  )r   r4  r  r   r   r   r   )csr  r  inner_csr  s        rX   r	  zLTestParforChunksizing.test_all_iterations_reset_chunksize.<locals>.test_impl  s    (1++Cwq#H)"--    a    A"'">"@"@HQKCFF                               = s   3A>>BB)i  i  i  i  rc  r   r  r   N)r   r  rO  r   all)rU   r	  r  r  r  r  s         rX   #test_all_iterations_reset_chunksizez9TestParforChunksizing.test_all_iterations_reset_chunksize  s    
 
t				! 	! 
		! ' 	7 	7A2YY 7 7 )	!A#q 1 1Xsby 1 1222x1} 5 566667	7 	7rZ   c                     |                      t                    5 }t          d             } |             d d d            n# 1 swxY w Y   d}|                     |t	          |j                             d S )Nc                  $    t          d           d S )NrK   r  r~   rZ   rX   neg_testzMTestParforChunksizing.test_njit_parallel_chunksize_negative.<locals>.neg_test2  s    &r*****rZ   /chunksize must be greater than or equal to zero)r  r   r   r   r#  r  )rU   rU  r  r   s       rX   %test_njit_parallel_chunksize_negativez;TestParforChunksizing.test_njit_parallel_chunksize_negative/  s    z** 	f+ + T+ HJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 @c3v/0011111s   AA	Ac                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   d}|                     |t	          |j                             d S )NrK   r  )r  r   r   r   r#  r  rU   rU  r   s      rX   'test_python_parallel_chunksize_negativez=TestParforChunksizing.test_python_parallel_chunksize_negative;  s    z** 	'f"2&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' @c3v/0011111   7;;c                     |                      t          j                  5 }t          d             } |             d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )Nc                  $    t          d           d S )Ninvalid_typer  r~   rZ   rX   r   zMTestParforChunksizing.test_njit_parallel_chunksize_invalid_type.<locals>.implE  s    &~66666rZ   )The parallel chunksize must be an integer)r  r   TypingErrorr   r   r#  r  )rU   rU  r   r   s       rX   )test_njit_parallel_chunksize_invalid_typez?TestParforChunksizing.test_njit_parallel_chunksize_invalid_typeC  s    v122 	f7 7 T7 DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 :c3v/0011111s   AAAc                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   d}|                     |t	          |j                             d S )Nr"  r#  )r  	TypeErrorr   r   r#  r  r  s      rX   +test_python_parallel_chunksize_invalid_typezATestParforChunksizing.test_python_parallel_chunksize_invalid_typeN  s    y)) 	3V">222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 :c3v/0011111r  N)ry   rP   rz   r[  r{   r  r  r  r  r
  r  r  r  r  r%  r(  r~   rZ   rX   r  r    s          "" " "" " "6 6 66 6 6& & & ! ! ! 7 7 70
2 
2 
22 2 2	2 	2 	22 2 2 2 2rZ   r  c                   Z    e Zd ZdZd Zed             Zed             Zed             ZdS )TestParforsVectorizerFc                    |                     dd          }|                     dd          }|                     dd          }|                     dd          }||d	}	g }
|	                                D ](\  }}|
                    t          ||                     )|
d
         5  |
d         5  t	          d |D                       }|                     |d           }|dk    r|                     ||          }n|                     ||          }|                     |          }|rt          j
        d          }|                    |j                                                  }|                     t          |          d           |                     |d
         |           |                     |i            |cd d d            cd d d            S # 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   Fcpu_namezskylake-avx512
assertionsTcpu_featuresz-prefer-256-bit)NUMBA_CPU_NAMENUMBA_CPU_FEATURESr   r   c                 6    g | ]}t          j        |          S r~   r   r   s     rX   r   z8TestParforsVectorizer.get_gufunc_asm.<locals>.<listcomp>o  s     777Qa777rZ   z%call\s+\w+\*\s+@do_scheduling_(\w+)\()r   rW  r   r9   r   r  r   r   r=  rA  r  findallr   r   r   r   r   assertNotEqual)rU   r   schedule_typer   r   r   r,  r-  r.  env_opts	overridesr   r  r   pfunc_vectorizabler   asmschedtymatchess                      rX   get_gufunc_asmz$TestParforsVectorizer.get_gufunc_asm]  s   ::j%00::j*:;;ZZd33
 zz.2CDD&.*6  	NN$$ 	8 	8DAq0A667777q\ 	 	9Q< 	 	77$77788C!%!:!:4!F!F4556H#NN,,-?EE &&t,,C -*%LMM!//$,*C*C*E*EFF''Ga888  ];;;##C,,,%	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s7   %	G/.DG>G/G	G/G	G//G36G3c                 t   d }t          j        d          }|                     |d|d          }|                     |d|d          }|                                D ]K}|                     d|v            |                     d|v pd	|v            |                     d
|v            L|                                D ]y}|                     d|v           |                     d|v           |                     d|v od	|v           |                     d|v            |                     d
|v           zdS ) This checks that if fastmath is set and the underlying hardware
        is suitable, and the function supplied is amenable to fastmath based
        vectorization, that the vectorizer actually runs.
        c                 z    t          |           }d}t          |          D ]}|t          j        |          z  }|S r  r   r  r   r   )r  r  r  r  s       rX   will_vectorizezJTestParforsVectorizer.test_vectorizer_fastmath_asm.<locals>.will_vectorize  s@    AAC1XX " "rwqzz!JrZ   r  r   Tr   Fvaddpdvsqrtpd__svml_sqrtzmmvsqrtsdvaddsdN)r   r4  r;  r  rO  )rU   r@  r  fast_asmslow_asmr  s         rX   test_vectorizer_fastmath_asmz2TestParforsVectorizer.test_vectorizer_fastmath_asm  sp   	 	 	 hrll&&~z304 ' 6 6&&~z305 ' 7 7"" 	( 	(A OOHM***OOIN@mq.@AAAOOEQJ''''"" 	, 	,AOOHA-...OOIQ.///OOINE}A/EFFFOOHM***OOEN++++	, 	,rZ   c                 f   d }d }t          j        d          }t          dd          5  |                     |d|d          }|                     |d	|d          }d
d
d
           n# 1 swxY w Y   |                                D ]G}|                     d|v           |                     d|v            |                     d|v           H|                                D ]K}|                     d|v pd|v            |                     d|v            |                     d|v            Ld
S )r=  c                     t          |           }t          | d          D ]}t          j        | |                   | |<    | S r  r?  r  r  r  s      rX   will_not_vectorizezTTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_not_vectorize  sB    AAA2q\\ % %wqt}}!HrZ   c                     t          |           }t          |          D ]}t          j        | |                   | |<    | S r\   r?  rM  s      rX   r@  zPTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_vectorize  s>    AA1XX % %wqt}}!HrZ   r  NUMBA_BOUNDSCHECK0r   TrA  r   NrC  rF  rE  rD  vmovupd)r   r4  r9   r;  r  rO  )rU   rN  r@  r  	novec_asmvec_asmr  s          rX   "test_unsigned_refusal_to_vectorizez8TestParforsVectorizer.test_unsigned_refusal_to_vectorize  s   	 	 		 	 	 hrll !!4c:: 	9 	9++,>#59 , ; ;I )).*c37 * 9 9G		9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 !!## 	, 	,AOOIQ.///OOIN+++OOEN++++!! 	( 	(A OOIN@mq.@AAAOOIN+++OOEQJ''''	( 	(s   3A**A.1A.c                    d }d }t          dd          5  |                     |dd          }|                     |dd          }d	d	d	           n# 1 swxY w Y   d
 }|                                D ]\  }} ||          } |                                D ]\  }} ||          }	 ddlm}
 |                     t          |          t          |	                     t          ||	          D ]i\  }}||k    r |
d ||          }|                                }|D ]8}|d         dk    r*|                     ||d         |d                  d           9jd	S )z This checks vectorization for signed vs unsigned variants of a
        trivial accumulator, the only meaningful difference should be the
        presence of signed vs. unsigned unpack instructions (for the
        induction var).
        c                  @    d} d}t          |  d          D ]}||z  }|S )N   r  r   r  r  s      rX   signed_variantzMTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.signed_variant  s5    AAA2q\\  QHrZ   c                  <    d} d}t          |           D ]}||z  }|S )NrX  r  r  r  s      rX   unsigned_variantzOTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.unsigned_variant  s1    AA1XX  QHrZ   rP  rQ  r   TrA  r   Nc                 D   g }|                                  D ]}|                                }|dk    rl|                    d          sW|                    d          sB|                    d          s-d|v s)|                    t	          j        dd|                     |S )N rJ   rL   "r0  z[	])r@  strip
startswithr   rA  sub)r8  r  r   spds       rX   strip_instrszKTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.strip_instrs  s    C^^%% < <ggii "99cnnS&9&99(+s(;(; (+s(;(;  )@3(F(F

26&"c#:#:;;;JrZ   r   )SequenceMatcherc                     | dk    S )N	r~   r1  s    rX   r  zGTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.<lambda>  s
    d rZ   insertr(  rK   r  )	r9   r;  rW  difflibrd  r   r   r   get_opcodes)rU   rY  r[  
signed_asmunsigned_asmrc  r   r  signed_instrunsigned_instrsmr   r   r  rQ  rT  s                   rX   test_signed_vs_unsigned_vec_asmz5TestParforsVectorizer.test_signed_vs_unsigned_vec_asm  s   	 	 		 	 	 !!4c:: 	> 	>,,^X6: - < <J../?8< / > >L	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>	 	 	 $$&& 	 	DAq'<??L &&(( 	 	DAq)\!__N111111 	\**C,?,?@@@n55 	@ 	@DAqAvvB**Aq11mmoo @ @B!u((((2b6"R&=)93???@	@ 	@s   1AAAN)	ry   rP   rz   r{   r;  r:   rJ  rU  ro  r~   rZ   rX   r*  r*  V  s        
 "# # #J %, %, Z%,N )( )( Z)(V =@ =@ Z=@ =@ =@rZ   r*  c                   $    e Zd ZdZd Zd Zd ZdS ) TestParforReductionSetNumThreadszCTest execution correctness on reductions with set_num_threads.
    c                     t           j        }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr   r   TrP  c                     d}t          |            t                    D ],}d|z  z   }t          |           t                      }||z  }-|S r  r   r   r   nthreadsr  r  
local_maskgntr:  masks        rX   udtz6TestParforReductionSetNumThreads.test_add.<locals>.udt"  a    CH%%%AYY  T\

+++%''s
JrZ   r   NUMBA_NUM_THREADSr   rQ  r  rU   r  rz  expectr  r:  ry  s        @@rX   test_addz)TestParforReductionSetNumThreads.test_add      $E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rZ   c                     t          dt          j                  }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr  r   r   TrP  c                     d}t          |            t                    D ],}d|z  z   }t          |           t                      }||z  }-|S r"  rt  ru  s        rX   rz  z6TestParforReductionSetNumThreads.test_mul.<locals>.udt8  r{  rZ   )r  r   r}  r   rQ  r  r~  s        @@rX   test_mulz)TestParforReductionSetNumThreads.test_mul1  s     6+,,E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rZ   c                     t           j        }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr   r   TrP  c                     d}t          |            t                    D ]7}d|z  z   }t          |           t                      }t          ||          }8|S r"  )r   r   r   r  ru  s        rX   rz  z6TestParforReductionSetNumThreads.test_max.<locals>.udtL  se    CH%%%AYY $ $T\

+++%''#smmJrZ   r|  r~  s        @@rX   r  z)TestParforReductionSetNumThreads.test_maxG  r  rZ   N)ry   rP   rz   r[  r  r  r  r~   rZ   rX   rq  rq    sK         - - -(- - -,- - - - -rZ   rq  c                   >    e Zd Z ej                    d             ZdS )TestDiagnosticEnvVarc                 
   dt           j        d<   t                      5 }t          d          d             } |             d d d            n# 1 swxY w Y   |                                }|                     d|           d S )N4NUMBA_PARALLEL_DIAGNOSTICSTrP  c                  x    d} t          j        | t           j                  }t          |           D ]}d||<   |S )Nr  r&  r   )r   r4  r  r   )r  r   r  s      rX   r   z<TestDiagnosticEnvVar.test_diagnostics_env_var1.<locals>.implb  sB    Ha
333  AAaDDrZ   zParallel Accelerator Optimizing)osenvironr7   r   r  r   )rU   r  r   
the_outputs       rX   test_diagnostics_env_var1z.TestDiagnosticEnvVar.test_diagnostics_env_var1^  s    14
/0 		&4     !  DFFF		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 __&&
7DDDDDs   $AAAN)ry   rP   rz   r6   run_test_in_subprocessr  r~   rZ   rX   r  r  \  s>        $X$&&E E '&E E ErZ   r  __main__r\   )mathr   rA  r  r   r  r|   r  
subprocessr   r  r  	functoolsr   r  r   numpy.randomr   rt  collectionsr   r	   r   	itertoolsr
   r   r  numba.parfors.parforr   r   r   r   r   r   r   r   r   
numba.corer   r   r   r   r   r   r   r   r   numba.extendingr   r   r    r!   r"   r#   numba.core.registryr$   numba.core.annotationsr%   numba.core.ir_utilsr&   r'   r(   r)   r*   r+   r,   numba.np.unsafe.ndarrayr-   r  numba.core.bytecoder.   numba.core.compilerr/   r0   r1   r2   numba.core.compiler_machineryr3   r4   numba.core.typed_passesr5   numba.tests.supportr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   numba.core.extendingrC   rD   rE   r  ri  rG   rj  r}   x86_onlyro  rp  r   r   r   rq  ry  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  rc  rl  r  r  rq  r|  r  ry  r  r  rs  r  r*  rq  r  ry   mainr~   rZ   rX   <module>r     s
         				 



  				  



                           / / / / / / / /  " " " " " " " "        = = = = = = = = = = = = = = = = = = = =Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q QF F F F F F F F F F F F F F F F * * * * * * 3 3 3 3 3 36 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 C B B B B B , , , , , ,5 5 5 5 5 5 5 5 5 5 5 5 E E E E E E E E 2 2 2 2 2 2( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (
 2 1 1 1 1 1 4 4 4 4 4 4         : : : : : : : :z 8?+8+--5GGYY  ,.@AA	 	 	 _ _ _ _ _h _ _ _D	       @ @ @D	 	 	A A A    $    "D D D
       D	 	 	
! 
! 
! 
! 
!6 
! 
! 
! h@ h@ h@ h@ h@o h@ h@ h@V 'K 'K 'K 'K 'Ko 'K 'K 'KT FO FO FO FO FOo FO FO FOR2 2 2 2 2X 2 2 2, SF SF SF SF SF/ SF SF SFl # # # # # # # #6 f% f% f% f% f% f% f% f%R	 "; "; "; "; "; "; "; ";J :M :M :M :M :M :M :M :Mz z z z z zo z z zz lD lD lD lD lD_ lD lD lD^P P P P P_ P P Pf a1 a1 a1 a1 a1n a1 a1 a1H V3 V3 V3 V3 V3 V3 V3 V3r w2 w2 w2 w2 w2H w2 w2 w2t 	~@ ~@ ~@ ~@ ~@N ~@ ~@ 
 ~@B ?- ?- ?- ?- ?-x ?- ?- ?-D E E E E E8 E E E$ zHMOOOOO rZ   