
    ,i~                    t   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
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, d dl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 d d	l4m5Z5 d d
l6m7Z7 d dl8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? d dl@mAZB d dlCmDZDmEZE d dlFmGZGmHZH d dlImJZJ d dlKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZY d dlZm[Z[ d dl\m]Z] d dl$m^Z^ d dl_Z_d dl`Z`eR G d deL                      Za e`jb         ejc                    dvd          ZddZedZf edd          Zgd ZheX G d deL                      Zid Zjd  Zkd! Zld" Zmd# Znd$ Zod% Zpd& Zqd' Zrd( Zsd) ZtdSd*Zud+ Zv G d, d-ew          ZxeR G d. d/ei                      ZyeR G d0 d1ei                      ZzeR G d2 d3ei                      Z{ G d4 d5eL          Z|eR G d6 d7ei                      Z}eR G d8 d9eNei                      Z~eR G d: d;ei                      ZeR G d< d=ei                      ZeR G d> d?ei                      ZeR G d@ dAei                      ZeR G dB dCei                      Z G dD dEei          ZeR G dF dGe                      ZeR G dH dIe                      ZeR G dJ dKeL                      ZeRed G dL dMe                                  ZeR G dN dOeL                      ZeR G dP dQeL                      ZedRk    r e`j                     dS dS )T    Nreducerandn)defaultdict
namedtuple)cyclechain)njitprangeparallel_chunksizeget_parallel_chunksizeset_parallel_chunksizeset_num_threadsget_num_threadstypeof)	types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)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skip_ppc64le_invalid_ctr_loop)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      V/var/www/html/speakWrite/venv/lib/python3.11/site-packages/numba/tests/test_parfors.pyrunnerzTestParforsRunner.runnerO   sk    ''))//#..r288==bA##/>,0M 	$ 	; 	; 	; 	; 	;    c                 .    |                                   d S NrU   rQ   s    rT   test_TestParforBasicz&TestParforsRunner.test_TestParforBasicW       rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforNumericalMiscz.TestParforsRunner.test_TestParforNumericalMiscZ   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforNumPyz&TestParforsRunner.test_TestParforNumPy]   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsz"TestParforsRunner.test_TestParfors`   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsBitMaskz)TestParforsRunner.test_TestParforsBitMaskc   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsDiagnosticsz-TestParforsRunner.test_TestParforsDiagnosticsf   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsLeaksz'TestParforsRunner.test_TestParforsLeaksi   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsMiscz&TestParforsRunner.test_TestParforsMiscl   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsOptionsz)TestParforsRunner.test_TestParforsOptionso   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsSlicez'TestParforsRunner.test_TestParforsSlicer   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestParforsVectorizerz,TestParforsRunner.test_TestParforsVectorizeru   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestPrangeBasicz&TestParforsRunner.test_TestPrangeBasicx   r\   rV   c                 .    |                                   d S rX   rY   rZ   s    rT   test_TestPrangeSpecificz)TestParforsRunner.test_TestPrangeSpecific{   r\   rV   N)__name__rL   __qualname___numba_parallel_test_platformmachinerP   rU   r[   r^   r`   rb   rd   rf   rh   rj   rl   rn   rp   rr   rt    rV   rT   rC   rC   A   s        " (x'))Y66ttDH
; ; ;                            rV   rC   )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.
    Nrz   abs     rT   null_comparerr      s	     	DrV   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dZddZd Zd Zd Zd Zd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                 D     t          |fi ||          j        |         S rX   )r   	overloads)rQ   funcsigflagss       rT   _compile_thiszTestParforsBase._compile_this   s,     "tC!!5!!$''1#66rV   c                 2    |                      ||d          S )NTparallelr   rQ   r   r   s      rT   compile_parallelz TestParforsBase.compile_parallel   s    !!$d!;;;rV   c                 4    |                      ||dd          S )NT)r   fastmathr   r   s      rT   compile_parallel_fastmathz)TestParforsBase.compile_parallel_fastmath   s    !!$dT!JJJrV   c                 .    |                      ||          S rX   r   r   s      rT   compile_njitzTestParforsBase.compile_njit   s    !!$,,,rV   c                     t          d |D                       }|                     ||          }|                     ||          }||fS )Nc                 6    g | ]}t          j        |          S rz   numbar   .0xs     rT   
<listcomp>z/TestParforsBase.compile_all.<locals>.<listcomp>        333U\!__333rV   )tupler   r   )rQ   pyfuncargskwargsr   cpfunccfuncs          rT   compile_allzTestParforsBase.compile_all   sV    33d33344 &&vs33 !!&#..f}rV   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      rT   	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??"rV   )
popentry_pointr   testingassert_almost_equalassertEqualtypelenzipr   )rQ   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                          rT   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 &%rV   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   rQ   r   r   r   r   r   s         rT   checkzTestParforsBase.check  sO     )(7$777v$$VUFLTLLLVLLLLLrV   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   )rQ   implarg_genr   r   s        rT   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)rQ   r   r   r   r   argtyss         rT   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unsignedrH   z$Unknown scheduler_type specified: %s)r   assertInlibraryget_llvm_str)rQ   cresr   scheduler_strmsgs        rT   r   z TestParforsBase.check_scheduling$  sj    (%!777~!55< ~!5666mT\%>%>%@%@AAAAArV   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   rT   genz)TestParforsBase.gen_linspace.<locals>.gen3  s[      +aA&&&&&+aA&&&&&+aA&&&&&&&rV   c                 .    g | ]}t                    S rz   )next)r   isrcs     rT   r   z0TestParforsBase.gen_linspace.<locals>.<listcomp>9  s    ---aS		---rV   )r	   range)rQ   r   ctr   r   s    `  @rT   gen_linspacezTestParforsBase.gen_linspace0  sP    	' 	' 	' 	' 	'
 CCEEll----599----rV   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     rT   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>B  s4     > > > ))F## > > >rV      )r   r   c                 6    g | ]}t          j        |          S rz   r   asfortranarrayr   s     rT   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>F  #    444r ##444rV   c                 8    g | ]}|                     d           S ))r   r     r  r   s     rT   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>I  s:     B B B ))I&& B B BrV      c                 6    g | ]}t          j        |          S rz   r  r   s     rT   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>M  r	  rV   N)r   )rQ   r   arr2dsarr3dss       rT   gen_linspace_variantsz%TestParforsBase.gen_linspace_variants;  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4rV   Nc                 X    fd|D             }||D ]}|t          |          v sJ |S )z. helper function to filter out modules by namec                 &    g | ]}|j         v |S rz   name)r   r   magicstrs     rT   r   z/TestParforsBase._filter_mod.<locals>.<listcomp>Q  s%    555a(af"4"4"4"4"4rV   )str)rQ   modr  checkstrfiltr   s     `   rT   _filter_modzTestParforsBase._filter_modO  sP    55553555 * *3q66)))))rV   c                     d |j         j        j        j        j        D             }|                     |||          }|j                                         }g }|D ] }|j        |v r|                    |           !|S )z gets the gufunc LLVM Modulesc                     g | ]}|S rz   rz   r   s     rT   r   z7TestParforsBase._get_gufunc_modules.<locals>.<listcomp>Y  s    JJJ!AJJJrV   )r  )	r   _codegen_engine_ee_modulesr  get_asm_strr  r   )	rQ   r   r  r  r   potential_matcheslib_asmretr  s	            rT   _get_gufunc_modulesz#TestParforsBase._get_gufunc_modulesW  s    JJt|4<@IJJJ !,,Xx6> - @ @ ,**,,$ 	  	 Cx7""

3
rV   c                     d}|                      ||          }t                      }|D ]} ||          ||j        <   |S )z$ helper for gufunc IR/asm generation__numba_parfor_gufunc)r%  dictr  )rQ   r   fnr  gufunc_modsr   r  s          rT   _get_gufunc_infoz TestParforsBase._get_gufunc_infof  sP     +..tX>>FF 	" 	"C"S''AchKKrV   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, ...)`
        )r+  r  )rQ   r   s     rT   _get_gufunc_irzTestParforsBase._get_gufunc_irp  s     $$T3///rV   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 rX   )r  emit_assembly)r  tms    rT   emit_asmz1TestParforsBase._get_gufunc_asm.<locals>.emit_asm  s    r'',,---rV   )r   r  _tmr+  )rQ   r   r2  r1  s      @rT   _get_gufunc_asmzTestParforsBase._get_gufunc_asmz  sA     \"&	. 	. 	. 	. 	.$$T8444rV   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        rT   _get_fast_instructionsz?TestParforsBase.assert_fastmath.<locals>._get_fast_instructions  sT    $r}HI ( (Ik1--=$$Q'''rV   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matchrQ   s         rT   _assert_fastz5TestParforsBase.assert_fastmath.<locals>._assert_fast  sj    JC + + # #BLE}}
	****+ +rV   N)r   r-  items)
rQ   r   r   r   _irr=  rM  r  guirrI  s
   `         rT   assert_fastmathzTestParforsBase.assert_fastmath  s     --fc::!!$''	 	 		+ 	+ 	+ 	+ 	+ ))++ 	 	JD$))$//DL	 	rV   rX   )ru   rL   rv   __doc__rw   r   r   r   r   r   r   r   r   r   r   r   r  r  r%  r+  r-  r4  rQ  rz   rV   rT   r   r      sN         "7 7 7
< < <K K K- - -	 	 	X5 X5 X5tM M M2 2 2G G G
B 
B 
B	. 	. 	.5 5 5(        0 0 05 5 5$ $ $ $ $rV   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   logsqrtexp)sptpricestrikerate
volatilitytimevlogtermpowtermdend1d2NofXd1NofXd2futureValuec1rE  puts                   rT   blackscholes_implrh    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JrV   c                     t          |          D ]O}|t          j        ddt          j        |  t          j        ||          z            z   z  dz
  | z  |          z  }P|S NrU  )r   r   dotrX  )YXw
iterationsr   s        rT   lr_implrp    sg    : N N	RVcS261"rva||*;#<#<<=CqH1MMMHrV   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 | ]B}t          j        t          j        d d f         |d d f         z
  dz                      CS Nr   )mathrW  r   sum)r   jA	centroidsr   s     rT   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  s_     ; ; ;$% )BFAacF9QqqqS>,AA+E$F$FGG ; ; ;rV   r   )r   r   rx  ry  	numCenters    @rT   r   z'example_kmeans_test.<locals>.<listcomp>  sc     N N N?@; ; ; ; ; ;).y)9)9; ; ; N N NrV   c                 L    g | ] }|d d f                                          !S rX   argmin)r   r   dists     rT   r   z'example_kmeans_test.<locals>.<listcomp>  s1    @@@!4!!!9++--@@@rV   c                 L    g | ]fd t                    D              S )c                     g | ];}t          j        k    |f                   t          j        k              z  <S rz   r   rv  )r   rw  rx  r   labelss     rT   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  sR     4 4 4%&  "va	1o66rvfai7H7HH 4 4 4rV   rz  )r   r   rx  Dr  s    @rT   r   z'example_kmeans_test.<locals>.<listcomp>  sa     O O O894 4 4 4 4 4*/((4 4 4 O O OrV   )shaper   r   array)
rx  r{  numIterinit_centroidsNlr  ry  r  r  s
   ``    @@@@rT   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		 rV   c                 Z   t           j        }t           j        }t          j        |           }|rt          j        |          }nt          j        d          }t          ||||          }|                                 |                                 t          j
        |j        j        |d          }|                                 t          j                            d|j                   t#          j        |j        j        |j        j        |j        j        |j        j        d           \  |j        _        |j        _        |j        _        }	t3          j        |j        j        |j        j        |j        j        dd |j        j        |j        j        t6          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%        |

  
        }|                                 tQ          |j)                  |_*        ||fS )	NT)typedzbefore-inferencerz   )func_irtypemap	calltypesliftedlifted_fromr   return_typehtml_output)swappedzafter-inference)diagnostics)+r"   typing_contexttarget_contextr   run_frontendr   ParallelOptionsTestPipelinerefreshr   InlineClosureCallPassstater  runr   rewrite_registryapplyr   type_inference_stage	typingctx	targetctxr   r  r  r  r#   TypeAnnotationr   HTMLr   parforsparforParforDiagnosticsPreParforPassreplaced_fnsFlags
ParforPassmetadataParforFusionPassParforPreLoweringPassr&   blocks_definitions)	test_funcr   kwsr  r  test_iroptionstpinline_passrH   r  preparfor_passr   parfor_passs                 rT   get_optimized_numba_irr    sy   )I)I#I..G
 ,%c**%d++	iD'	:	:B$:28;K<CBFH H HK OO##$6AAA %bh&8
BH,bhmTC C BBHbh*BH,> #  ($X]H(K! ! ! ! -&88::K])77
"(*BH,>
BH.( 8 * *N ##$5rx@@@NE-&11
"(*BH,>
bh0"(2D){ 2 D DK OO-&77
"(*BH,>
bh0"(2D){ 8 D DK OO-&<<
"(*BH,>
bh0"(2D){ = D DK OO,W^<<GB;rV   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  rN  	enumeratebodyr   r   r  r  Parfor)
r  r   r  r  r  	ret_countlabelblockr   rI  s
             rT   r   r     s    (D@@C@@KGRI,,..  u ,, 	 	GAt$ 4 ;<< Q		 rV   c                 b    t          | |fi |\  }}t          |j        |j        j                  S rX   )r  _count_arrays_innerr  r  r  r  r   r  r  r  s        rT   countArraysr    s4    (D@@C@@KGRw~rx/?@@@rV   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  rN  r  r  r   r   r  r  r  r   
init_block)r  r   r  r  r  r  r  r  r  r   rI  s              rT   get_init_block_sizer  #  s    (D@@C@@KGR^FI 7 7u ,, 	7 	7GAt$ 4 ;<< 7S!5666		7 rV   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  )setrN  r  r  r   r   r  r  r  	loop_bodyr   r  r  r   Assigntargetr  r   ArrayCompatibleaddr   )	r  r  r  arr_setr  r  r   rI  parfor_blockss	            rT   r  r  0  s   IeeG 	. 	.u ,, 	. 	.GAt$ 4 ;<< I $ 3 3 5 5#'?a 0HHH	4++ ."74;+;#<$)$9; ;. DK,---	. WIrV   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          rT   countArrayAllocsr  B  s\    (D@@C@@KGRI&&(( ? ?.w>>>		rV   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   rE  )emptynumpy)r+   znumba.np.unsafe.ndarrayr   )r  r   r   r  r  r  r  r  r  r  r   r  valueExprrK  r%   r$   )r  r  r  rI  r   s        rT   r  r  K  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rV   c                 d    t          | |fi |\  }}t          ||j        |j        j                  S rX   )r  &_count_non_parfor_array_accesses_innerr  r  r  r  s        rT   countNonParforArrayAccessesr  \  s@    (D@@C@@KGR1'7>24(2BD D DrV   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  rN  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	            rT   r  r  a  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 rV   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 rX   r  )r   vs     rT   	<genexpr>z _uses_indices.<locals>.<genexpr>  s$      55!qv555555rV   r   F)
r  r%   r'   r   r   r  rK  r  rN  r   )r  index	index_setind_defvarnamess        rT   r  r    s    zYtND%00G'27## .
m(C(C55w}555558i'((A--5rV   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 rX   )r   	StateDictr  r  r  r   r  r  r  r  r  )rQ   r  r  r   r  s        rT   __init__zTestPipeline.__init__  sg    '))
(
(

$
!
!%
#
 
rV   N)ru   rL   rv   r  rz   rV   rT   r  r    s#        	! 	! 	! 	! 	!rV   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)rQ   r   r<  s      rT   r  zTestParforBasic.__init__  s]     -----Jry~~v..IbMM29R==!QSArV   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 )Nrz   r   onesrz   rV   rT   	test_implz0TestParforBasic.test_simple01.<locals>.test_impl  s    72;;rV   '@do_scheduling' not foundassertRaisesAssertionErrorr   r   r  	exceptionrQ   r  raisess      rT   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  rz   rV   rT   r  z0TestParforBasic.test_simple02.<locals>.test_impl  s    74== rV   r   rQ   r  s     rT   test_simple02zTestParforBasic.test_simple02  s)    	! 	! 	!

9rV   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S Nr   r   r  rz   rV   rT   r  z0TestParforBasic.test_simple03.<locals>.test_impl      76??"rV   r  r  s     rT   test_simple03zTestParforBasic.test_simple03  )    	# 	# 	#

9rV   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S Nr   r  rz   rV   rT   r  z0TestParforBasic.test_simple04.<locals>.test_impl  s    71::rV   r  r  s     rT   test_simple04zTestParforBasic.test_simple04  s)    	 	 	

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

9rV   c                 6    d }|                      |           d S )Nc                  T    t          j        d          t          j        d          z   S r  r  rz   rV   rT   r  z0TestParforBasic.test_simple08.<locals>.test_impl  s    76??RWV__44rV   r  r  s     rT   test_simple08zTestParforBasic.test_simple08  s)    	5 	5 	5

9rV   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r   r  rz   rV   rT   r  z0TestParforBasic.test_simple09.<locals>.test_impl  r  rV   r  r  s     rT   test_simple09zTestParforBasic.test_simple09  r  rV   c                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r   r  rz   rV   rT   r  z0TestParforBasic.test_simple10.<locals>.test_impl  r  rV   r  r  s     rT   test_simple10zTestParforBasic.test_simple10  r  rV   c                 6    d }|                      |           d S )Nc                  0    t          j        d          dz   S Nr   r   rU  r  rz   rV   rT   r  z0TestParforBasic.test_simple11.<locals>.test_impl  s    78$$r))rV   r  r  s     rT   test_simple11zTestParforBasic.test_simple11  s)    	* 	* 	*

9rV   c                 6    d }|                      |           d S )Nc                  T    t          j        d          t          j        d          z   S r2  r"  rz   rV   rT   r  z0TestParforBasic.test_simple12.<locals>.test_impl  s!    78$$r}R'8'888rV   r  r  s     rT   test_simple12zTestParforBasic.test_simple12  s)    	9 	9 	9

9rV   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 rj  )r   r#  rz   rV   rT   r  z0TestParforBasic.test_simple13.<locals>.test_impl  s    =$$$rV   r  r  r	  s      rT   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 )Nr3  r      r  rz   rV   rT   r  z0TestParforBasic.test_simple14.<locals>.test_impl  s    78$$QUU++rV   r  r  s     rT   test_simple14zTestParforBasic.test_simple14  s)    	, 	, 	,

9rV   c                 2    d } | j         |g| j        R   d S )Nc                     | | z   S rX   rz   v1v2m1m2s       rT   r  z0TestParforBasic.test_simple15.<locals>.test_impl      7NrV   r   r  r  s     rT   test_simple15zTestParforBasic.test_simple15  4    	 	 	
90t/000000rV   c                 2    d } | j         |g| j        R   d S )Nc                     ||z   S rX   rz   rA  s       rT   r  z0TestParforBasic.test_simple16.<locals>.test_impl  rF  rV   rG  r  s     rT   test_simple16zTestParforBasic.test_simple16  rI  rV   c                 2    d } | j         |g| j        R   d S )Nc                     || z   S rX   rz   rA  s       rT   r  z0TestParforBasic.test_simple17.<locals>.test_impl  rF  rV   rG  r  s     rT   test_simple17zTestParforBasic.test_simple17  rI  rV   c                 2    d } | j         |g| j        R   d S )Nc                 \    |j         t          j                            |          d         z   S r  )r  r   linalgsvdrA  s       rT   r  z0TestParforBasic.test_simple18.<locals>.test_impl  s"    4")--++A...rV   rG  r  s     rT   test_simple18zTestParforBasic.test_simple18  s4    	/ 	/ 	/
90t/000000rV   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||          S rX   r   rk  rA  s       rT   r  z0TestParforBasic.test_simple19.<locals>.test_impl      6"b>>!rV   rG  r  s     rT   test_simple19zTestParforBasic.test_simple19  4    	" 	" 	"
90t/000000rV   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 rX   rW  rA  s       rT   r  z0TestParforBasic.test_simple20.<locals>.test_impl  rX  rV   r  )r  r  r   r  r   r  r  r	  s      rT   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 rX   rW  rA  s       rT   r  z0TestParforBasic.test_simple21.<locals>.test_impl  rX  rV   rG  r  s     rT   test_simple21zTestParforBasic.test_simple21  rZ  rV   c                 2    d } | j         |g| j        R   d S )Nc                 0    t          j        | | z             S rX   r  rA  s       rT   r  z0TestParforBasic.test_simple22.<locals>.test_impl  s    6"r'??"rV   rG  r  s     rT   test_simple22zTestParforBasic.test_simple22  s4    	# 	# 	#
90t/000000rV   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  )rB  rC  rD  rE  r   ys         rT   r  z0TestParforBasic.test_simple23.<locals>.test_impl  s>    BABArvadQTkAo...33rV   rG  r  s     rT   test_simple23zTestParforBasic.test_simple23  s6    	4 	4 	4 	
90t/000000rV   c                 6    d }|                      |           d S )Nc                      d} t          j        | | f          }t          j        |           }t          j        |d d |f                   S )Nr=  )r   r  r  rv  )r   rx  r   s      rT   r  z0TestParforBasic.test_simple24.<locals>.test_impl  s?    AAA	!A6!AAAqD'??"rV   r  r  s     rT   test_simple24zTestParforBasic.test_simple24  s+    	# 	# 	#
 	

9rV   c                 2    d } | j         |g| j        R   dS )zAsame as corresponding test_simple_<n> case but using operator.addc                 ,    t          j        | |           S rX   operatorr  rA  s       rT   r  z:TestParforBasic.test_simple_operator_15.<locals>.test_impl(      <B'''rV   NrG  r  s     rT   test_simple_operator_15z'TestParforBasic.test_simple_operator_15%  s6    	( 	( 	( 	
90t/000000rV   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||          S rX   rm  rA  s       rT   r  z:TestParforBasic.test_simple_operator_16.<locals>.test_impl/  ro  rV   rG  r  s     rT   test_simple_operator_16z'TestParforBasic.test_simple_operator_16-  6    	( 	( 	( 	
90t/000000rV   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||           S rX   rm  rA  s       rT   r  z:TestParforBasic.test_simple_operator_17.<locals>.test_impl6  ro  rV   rG  r  s     rT   test_simple_operator_17z'TestParforBasic.test_simple_operator_174  rt  rV   c                 l    d }d }t          j        d          }|                     |||g           d S )Nc                     | dz  } d| d d <   d S )Nr   r  rz   r   s    rT   r  z5TestParforBasic.test_inplace_alias.<locals>.test_impl=  s    FAAaaaDDDrV   c                 F    t           j                            | |           d S rX   r   r   assert_equalr   s     rT   comparerz4TestParforBasic.test_inplace_alias.<locals>.comparerA       J##Aq)))))rV   r   r   r   r  r   )rQ   r  r~  r   s       rT   test_inplace_aliasz"TestParforBasic.test_inplace_alias;  sO    	 	 		* 	* 	* GAJJ

9aXJ
?????rV   N)"ru   rL   rv   rR  r  r  r  r  r  r$  r'  r+  r/  r4  r7  r:  r>  rH  rL  rO  r:   rT  r9   rY  r]  r`  rc  rg  rj  r;   rp  rs  rw  r  rz   rV   rT   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
@ 
@ 
@ 
@ 
@rV   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ranfrv  )r   r   rf  s      rT   r  z2TestParforNumericalMisc.test_pi.<locals>.test_implM  sf    BINN1%%%)ABINN1%%%)ArvadQTkAo...22rV   i r   decimalr   )r   r   r   r   int64r  intpr  s     rT   test_pizTestParforNumericalMisc.test_piL  sy    	3 	3 	3
 	

9fa
000i%+AA1EEEY>>BBBBBrV   c                     t           j        d d          fdz  }|                     t          t          |          d           d S Nr~   r   )r   float64r   r   rh  rQ   r   s     rT   test_blackscholesz)TestParforNumericalMisc.test_blackscholesV  sA    aaa #a'&7>>BBBBBrV   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   rp  r  r  s     rT   test_logistic_regressionz0TestParforNumericalMisc.test_logistic_regression[  s    aaa %-!!!"4emAAA6Fgt44a888)'488!<<<<<rV   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  )rQ   r  r  centersrx  r  arg_typss          rT   test_kmeansz#TestParforNumericalMisc.test_kmeansb  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rV   N)	ru   rL   rv   rR  r  r  r9   r  r  rz   rV   rT   r  r  H  sm        55C C CC C C
 = = Z=K K K K KrV   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 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 rX   rW  r   r  s     rT   r  z-TestParforNumPy.test_mvdot.<locals>.test_imply      6!Q<<rV   r   r   r=  r   r   )r   r   r  r   )rQ   r  rx  r  s       rT   
test_mvdotzTestParforNumPy.test_mvdotw  se    	  	  	  K1b!!))!R00K1b!!

9a#####rV   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 rX   r   r  rv  )r   rx  r  BrK  s       rT   r  zBTestParforNumPy.test_fuse_argmin_argmax_max_min.<locals>.test_impl  s3    GAJJBqEEEEGG1urV      r   r   )r   r~  argmaxminmaxr   r   r   r   r  r  r  )rQ   r  rK  s     @rT   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rV   c                 j    d }|                      t          |t          j        f          d           d S )Nc                 0    t          |           }|d         S r  r   r   rx  s     rT   r  zDTestParforNumPy.test_np_random_func_direct_import.<locals>.test_impl  s    aAQ4KrV   r   r   r   r   r  r  s     rT   !test_np_random_func_direct_importz1TestParforNumPy.test_np_random_func_direct_import  s=    	 	 	 	i%+AA1EEEEErV   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 rX   r   r  r   s    rT   
test_impl1z/TestParforNumPy.test_arange.<locals>.test_impl1      9Q<<rV   c                 ,    t          j        | |          S rX   r  sr   s     rT   
test_impl2z/TestParforNumPy.test_arange.<locals>.test_impl2  s    9Q??"rV   c                 .    t          j        | ||          S rX   r  r  r   ts      rT   
test_impl3z/TestParforNumPy.test_arange.<locals>.test_impl3  s    9Q1%%%rV               >@r  r~   r   complexr   rQ   r  r  r  args        rT   test_arangezTestParforNumPy.test_arange  s    	  	  	 	# 	# 	#	& 	& 	& T71Q<<1> 	. 	.CJJz3'''JJz1c***JJz1c1----	. 	.rV   c                     d }d }d }dD ]G}|                      ||           |                      |d|           |                      |d|d           Hd S )Nc                 B    t          j        | t           j                  S Nr   r   r  float32r   s    rT   r  z5TestParforNumPy.test_arange_dtype.<locals>.test_impl1  s    9Qbj1111rV   c                 D    t          j        | |t           j                  S r  r  r  s     rT   r  z5TestParforNumPy.test_arange_dtype.<locals>.test_impl2  s    9Q4444rV   c                 F    t          j        | ||t           j                  S r  r  r  s      rT   r  z5TestParforNumPy.test_arange_dtype.<locals>.test_impl3  s    9Q1BJ7777rV   )r  r  r  r   r  r  s        rT   test_arange_dtypez!TestParforNumPy.test_arange_dtype  s    	2 	2 	2	5 	5 	5	8 	8 	8 # 	. 	.CJJz3'''JJz1c***JJz1c1----	. 	.rV   c                     d }d }dddt          dd          t          dd          fD ]1}|                     |d|           |                     |d|d	           2d S )
Nc                 ,    t          j        | |          S rX   r   )startstops     rT   r  z1TestParforNumPy.test_linspace.<locals>.test_impl1  s    ;ud+++rV   c                 .    t          j        | ||          S rX   r   )r  r  nums      rT   r  z1TestParforNumPy.test_linspace.<locals>.test_impl2  s    ;udC000rV   r  r  r  r  r~   r      r  )rQ   r  r  r  s       rT   test_linspacezTestParforNumPy.test_linspace  s    	, 	, 	,	1 	1 	1 T71Q<<1> 	/ 	/CJJz1c***JJz1c2....	/ 	/rV   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 rX   meanrx  s    rT   r  z,TestParforNumPy.test_mean.<locals>.test_impl  s    6688OrV   d   r   r  sizer   r  r   c                  .                          d          S r  r  rZ   s   rT   <lambda>z+TestParforNumPy.test_mean.<locals>.<lambda>      455a88 rV   r   r  r  randintr   r   r   r   r  r  r   r   )rQ   r  r  rx  r  data_gens   `     rT   	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8rV   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 rX   )varr  s    rT   r  z+TestParforNumPy.test_var.<locals>.test_impl      5577NrV   r  r   r  r                ?r   r  r   c                  .                          d          S r  r  rZ   s   rT   r  z*TestParforNumPy.test_var.<locals>.<lambda>  r  rV   r  )rQ   r  r  rx  r  r  r  s   `      rT   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8rV   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 rX   )stdr  s    rT   r  z+TestParforNumPy.test_std.<locals>.test_impl  r  rV   r  r   r  r  r  r   r  r   c                  .                          d          S r  r  rZ   s   rT   r  z*TestParforNumPy.test_std.<locals>.<lambda>  r  rV   )r   r  r  r  r   r   r  r  r   r   r   r   )rQ   r  r  rx  r  r  argtyr  s   `       rT   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8rV   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 rX   )r   r  r  r  s     rT   r  z5TestParforNumPy.test_random_parfor.<locals>.test_impl  s    	1v&&AHrV   r   Nr  r  s     rT   test_random_parforz"TestParforNumPy.test_random_parfor  s=    
	 	 	 	i%+AA1EEEEErV   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          rU  r   r  )highr  r   )	r   r  standard_normalr   normal	chisquarer  
triangularrv  r   rx  r  r  r  EFs          rT   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+&&&rV   r  g?)rtolr   )r   r   r   r   r   r   assert_allcloser   r   r   r  rQ   r  r   r   r   	py_outputs         rT   test_randomszTestParforNumPy.test_randoms  s    	' 	' 	' &&y5<??2DEE**1--IaLL	

""=)$"GGGi%+AA1EEEEErV   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          rT   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1rV   r  r   )r   r   r   r   r   r   r   r  r  s         rT   test_dead_randomsz!TestParforNumPy.test_dead_randoms  s    	 	 	 &&y5<??2DEE**1--IaLL		222i%+AA1EEEEErV   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 rX   r  r  s    rT   r  z,TestParforNumPy.test_min.<locals>.test_impl1!  r  rV   c                 *    t          j        |           S rX   )r   r  r  s    rT   r  z,TestParforNumPy.test_min.<locals>.test_impl2$      6!99rV      r   r  zDzero-size array to reduction operation minimum which has no identityr   c                  .                          d          S r  r  rZ   s   rT   r  z*TestParforNumPy.test_min.<locals>.<lambda>?  r  rV   r   r  r  r  astypeint32r  infr   r   r   r  r  r   r   r   r  r  r   r   rQ   r  r  r   rx  r  r  r  r   r   pcfuncer  s   `            rT   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 rX   )r  r  s    rT   r  z,TestParforNumPy.test_max.<locals>.test_impl1F  r  rV   c                 *    t          j        |           S rX   )r   r  r  s    rT   r  z,TestParforNumPy.test_max.<locals>.test_impl2I  r  rV   r  r   r  zDzero-size array to reduction operation maximum which has no identityr   c                  .                          d          S r  r  rZ   s   rT   r  z*TestParforNumPy.test_max.<locals>.<lambda>d  r  rV   r  r  s   `            rT   test_maxzTestParforNumPy.test_maxE  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 rX   )r  r  s    rT   r  z/TestParforNumPy.test_argmax.<locals>.test_impl1k      88::rV   c                 *    t          j        |           S rX   )r   r  r  s    rT   r  z/TestParforNumPy.test_argmax.<locals>.test_impl2n  r  rV   r  )rU  r  r         @r  r   r  rU  r  r$  r  z*attempt to get argmax of an empty sequencer   c                  .                          d          S r  r  rZ   s   rT   r  z-TestParforNumPy.test_argmax.<locals>.<lambda>  r  rV   r   r  r  r  r  r  r  nanr   r   r   r  r  r   r   r   r  r  r   r   r  s   `            rT   test_argmaxzTestParforNumPy.test_argmaxj     	 	 		  	  	  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 rX   r}  r  s    rT   r  z/TestParforNumPy.test_argmin.<locals>.test_impl1  r"  rV   c                 *    t          j        |           S rX   )r   r~  r  s    rT   r  z/TestParforNumPy.test_argmin.<locals>.test_impl2  r  rV   r  )rU  r  r$  r  r  r   r  rU  r  r  z*attempt to get argmin of an empty sequencer   c                  .                          d          S r  r  rZ   s   rT   r  z-TestParforNumPy.test_argmin.<locals>.<lambda>  r  rV   r&  r  s   `            rT   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    rT   r  z4TestParforNumPy.test_ndarray_fill.<locals>.test_impl      FF3KKKHrV   r   r   r  r   zerosr   r   r  r  r   r   rQ   r  r   r  s       rT   test_ndarray_fillz!TestParforNumPy.test_ndarray_fill  sr    	 	 	 HRLL

9a   U]As335i77;;;;;rV   c                     d }t          j        d          }|                     ||           t          j        t          j        dd          f}|                     t          ||          d           d S )Nc                 0    |                      d           | S r2  r4  r6  s    rT   r  z6TestParforNumPy.test_ndarray_fill2d.<locals>.test_impl  r7  rV   r   r   r   r  r   r8  r:  s       rT   test_ndarray_fill2dz#TestParforNumPy.test_ndarray_fill2d  sr    	 	 	 HUOO

9a   U]As335i77;;;;;rV   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   rG   r   r9  r  r  r  r   r   result_matrixsub_azresult_datas         rT   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%   rV   rU  r$  r  r        @      @r3  g       @g      "@      $@g      &@r  r  r   r  r   rQ   r  r   r   s       rT   test_reshape_with_neg_onez)TestParforNumPy.test_reshape_with_neg_one  T    	! 	! 	! H 4 4 4 5 5

9a#####rV   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   irC  rD  s         rT   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%   rV   rI  r  rM  rN  s       rT   test_reshape_with_large_negz+TestParforNumPy.test_reshape_with_large_neg  rP  rV   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 )NTr   c                     t          j        ||dft           j                  }| d|         }|j        } | dz  }|                    dd          }||z  }||d d d d df<   |S rB  rC  )r   r   rmrF  rG  rH  s         rT   r  zETestParforNumPy.test_reshape_with_too_many_neg_one.<locals>.test_impl  ss    Xq!Qirz:::!A#JEMM"b))#ai'111QQQq5		rV   rI  r  z7The reshape API may only include one negative argument.)	r  r   UnsupportedRewriteErrorr   r   r  r   r  r  )rQ   raisedr  r   r   r   s         rT   "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 rX   )r   rv  prodr  r  r  r   s    rT   r  z0TestParforNumPy.test_0d_array.<locals>.test_impl  sD    6!99rwqzz)BF1II5q		ABF1IIMMrV      Fr   )r   r   r  r  s     rT   test_0d_arrayzTestParforNumPy.test_0d_array  s:    	N 	N 	N

9bhqkkE
BBBBBrV   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 rt  )r   rv  realimag)rG  s    rT   r  z6TestParforNumPy.test_real_imag_attr.<locals>.test_impl  s#    6!&A+!3444rV   r~   y      ?      ?r   )r   r  r   r   r   r   r#  )rQ   r  rG  s      rT   test_real_imag_attrz#TestParforNumPy.test_real_imag_attr  sp    	5 	5 	5 IaLLF#

9a   i%2B33Q32G1IJJANNNNNrV   N)ru   rL   rv   rR  r9   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r(  r/  r;  r?  rO  rS  rY  r_  rd  rz   rV   rT   r  r  s  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rV   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.
        Tr   c                 ,    t          j        | |          S rX   rW  r  s     rT   ddotzHTestParforsUnsupported.test_unsupported_combination_raises.<locals>.ddot  s    va||#rV   r   r   r=  r   r   NzCThe 'parallel' target is not currently supported on 32 bit hardware)
r  r   UnsupportedParforsErrorr   r   r   r  r   r  r  )rQ   rX  ri  rx  r  r   s         rT   #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)	ru   rL   rv   rR  unittestskipIfr8   r9   rk  rz   rV   rT   rf  rf    sP        ..X_Z!?@@2 2 Z A@2 2 2rV   rf  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 ZKdH ZLdI ZMdJ ZNdK ZOdL ZPeQeRdM                         ZSdNS )OTestParforsz6 Tests cpython, reduction and various parfors featuresc                 @     d }                      | fd           d S )Nc                     | |z  |z   S rX   rz   )r   r   rf  s      rT   r  z,TestParfors.test_arraymap.<locals>.test_impl(  s    q519rV   c                  .                          d          S Nr  r  rZ   s   rT   r  z+TestParfors.test_arraymap.<locals>.<lambda>+  s    t/I/I!/L/L rV   )r   r  s   ` rT   test_arraymapzTestParfors.test_arraymap'  s:    	 	 	 	I'L'L'L'LMMMMMrV   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S )Nr   r      )r   r  r  rv  rm  rl  s     rT   r  z0TestParfors.test_0d_broadcast.<locals>.test_impl.  s0    A!!A6!a%== rV   rz   r   r   r   r   r  s     rT   test_0d_broadcastzTestParfors.test_0d_broadcast-  K    	! 	! 	! 	

9i44a88888rV   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S Nrw  )r   r  r9  rv  ry  s     rT   r  z-TestParfors.test_2d_parfor.<locals>.test_impl6  s2    !!A""A6!a%== rV   rz   r   rz  r  s     rT   test_2d_parforzTestParfors.test_2d_parfor5  r|  rV   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  r9  ry  s     rT   case1z)TestParfors.test_nd_parfor.<locals>.case1>  s5      !!A""Aa&LLLLLrV   c                  Z    t                                            d                    S rt  )r
   r  )r  rQ   s   rT   r  z,TestParfors.test_nd_parfor.<locals>.<lambda>C  s%    5$*D*DQ*G*GHH rV   c                 0    t          j        | |z             S rX   r  ry  s     rT   r  z-TestParfors.test_nd_parfor.<locals>.test_implE  s    6!a%== rV   )r   r   )rQ   r  r  r  s   `  @rT   test_nd_parforzTestParfors.test_nd_parfor=  sj    	 	 	
 IHHHH	! 	! 	! 	Ix000##Ix88888rV   c                 N    ddl m fd}d}|                     ||           d S )Nr   )r  c                 *     |           }|d         S r  rz   )r   rx  r  s     rT   r  z9TestParfors.test_np_func_direct_import.<locals>.test_implM  s    QAQ4KrV   o   )r  r  r   )rQ   r  r   r  s      @rT   test_np_func_direct_importz&TestParfors.test_np_func_direct_importK  sO    	 	 	 	 	 

9a     rV   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 rX   r  )r<  r   rx  r  s       rT   r  z2TestParfors.test_size_assertion.<locals>.test_implT  s.    

A

A6!a%== rV   r   Tr   	   zSizes of A, B do not match)r   r  r  r   r   r  r  )rQ   r  r
  r   r   s        rT   test_size_assertionzTestParfors.test_size_assertionS  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   rw  s        rT   r  z'TestParfors.test_cfg.<locals>.test_implb  ss    \!__ + +!Q1a
44 + +A%&KNtaxx)*A+
 rV   r  )r   r  randr9  r   )rQ   r  r  r   r  s        rT   test_cfgzTestParfors.test_cfg`  sV    	 	 	 INN1hqkk

9aa00000rV   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 rX   r  r   s     rT   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>s  s    c!Qii rV   r   )rx  init_vals     rT   r  z*TestParfors.test_reduce.<locals>.test_implq  s    H//H===rV   r  r   r  c                  R    d } t          | t          j        g d          d          S )Nc                     | dz  S rt  rz   r6  s    rT   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>}  s
    !q& rV   r   r   r  r  r~   r   )r   r   r  )gs    rT   r  z*TestParfors.test_reduce.<locals>.test_impl|  s*      A!RXooo66:::rV      c                 >    t          j        | | dk                       S rs  r  r  s    rT   r  z*TestParfors.test_reduce.<locals>.test_impl  s    6!AqD'??"rV   c                 Z    | d d df         }t          j        | |dk    df                   S )Nr   r  r   r  rx  r  s     rT   r  z*TestParfors.test_reduce.<locals>.test_impl  s/    !!!A#A6!AqDF)$$$rV   )   r   c                 ^    | d d df         }t          j        | |dk    ddf                   S )Nr   r  r   r   r  r  s     rT   r  z*TestParfors.test_reduce.<locals>.test_impl  s3    !!!A#A6!AqD1H+&&&rV   r   c                 4    t          j        |           }| |z
  S rX   )r   amin)rx  min_vals     rT   r  z*TestParfors.test_reduce.<locals>.test_impl  s    gajjGw;rV   )r   r  r  r   r  r  r  assertTypingErrorr  r   r   r   r  rQ   r  r   rx  s       rT   test_reducezTestParfors.test_reducep  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   cmathrW  accr   s     rT   r  z9TestParfors.test_use_of_reduction_var1.<locals>.test_impl  s0    CAYY & &jooJrV   CUse of reduction variable acc in an unsupported reduction function.rz   r  r   r   r   r  r  rQ   r  r   r  r  s        rT   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     rT   r  z9TestParfors.test_unsupported_floordiv1.<locals>.test_impl  s,    CAYY  	JrV   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.rz   )r  r   NumbaValueErrorr   r   r  r  r  s        rT   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     rT   r  z4TestParfors.test_unsupported_xor1.<locals>.test_impl  s0    CAYY  q1uJrV   r  rz   r  r  s        rT   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 rX   r  r  s     rT   r  z8TestParfors.test_parfor_array_access1.<locals>.test_impl  s    

A5577NrV   r  r   )r   r   r  r   r  rQ   r  r   s      rT   test_parfor_array_access1z%TestParfors.test_parfor_array_access1  sV    	 	 	 

9a   Y>>BBBBBrV   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   rx  r<  r   s       rT   r  z8TestParfors.test_parfor_array_access2.<locals>.test_impl  s    

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

9a   4YNNPQRRRRRrV   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       rT   r  z8TestParfors.test_parfor_array_access3.<locals>.test_impl  s_    28$$AA\#a&&))  QqT	a44A rV   r  z Overwrite of parallel loop index)r  r   rW  r   r   r  r  )rQ   r  r   r
  s       rT   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 rX   rW  )rx  r   s     rT   r  z8TestParfors.test_parfor_array_access4.<locals>.test_impl  r  rV   r  r  r   r  r   r   FTr  )r   r  r  r   r  r   r  r  rF  r   r  r  r   r   r  r  r  r  r  r   r  r  r  rK  r  rN  )rQ   r  r   drx  r   r  r  r  parfor_foundr  r  build_tuple_foundbls                 rT   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 	)*****rV   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     rT   r  z5TestParfors.test_parfor_dtype_type.<locals>.test_impl   sA    \#a&&)) ' 'w||A!Q4KrV   r   r  )rQ   r  r   s      rT   test_parfor_dtype_typez"TestParfors.test_parfor_dtype_type  s:    	 	 	
 GBKK

9a     rV   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   rv  )r   rm  rf  r   s       rT   r  z8TestParfors.test_parfor_array_access5.<locals>.test_impl*  sT    AAA\!__ " "QqsVZZ\\!HrV   r  r   r  r  s      rT   test_parfor_array_access5z%TestParfors.test_parfor_array_access5(  sX    	 	 	 

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

9c"""""rV   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 rs  )r   r  r   rk  )r  r  rn  rm  rl  r   r  s          rT   r  z8TestParfors.test_parfor_generate_fuse.<locals>.test_implC  s_    

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

A1XX ( (R"&A,,&HrV   r  r  r  )r   r   r  r   r  r   )rQ   r  r   r  s       rT   test_parfor_generate_fusez%TestParfors.test_parfor_generate_fuse@  s    	 	 	 

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

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

9b!!!!!rV   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  )rx  condr  r   s       rT   r  z8TestParfors.test_non_identity_initial.<locals>.test_implv  s?    AAGAJ''  7 FAHrV   r   boolr   r   r  r  r  s     rT   test_non_identity_initialz%TestParfors.test_non_identity_initialt  sM    	 	 	 	

9bgbkk272;;+=+=f+E+EFFFFFrV   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  )rx  r  r  r  r   s        rT   r  z9TestParfors.test_if_not_else_reduction.<locals>.test_impl  s]    AAAGAJ''  7 FAFAAFAAq5LrV   r   r  r  r  s     rT   test_if_not_else_reductionz&TestParfors.test_if_not_else_reduction~  sM    		 		 		 	

9bgbkk272;;+=+=f+E+EFFFFFrV   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   r9  int_r  r  r   r   r   shpr  result1tmpr   s         rT   r  z?TestParfors.test_two_d_array_reduction_reuse.<locals>.test_impl  s    Cq6CF?DhsBG,,G)D//))#..C\!__  3\!__  3NrV   r  r  r  s     rT    test_two_d_array_reduction_reusez,TestParfors.test_two_d_array_reduction_reuse  s-    	 	 	 	

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

9c"""""rV   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         rT   r  z9TestParfors.test_two_d_array_reduction.<locals>.test_impl  sm    Cq6CF?DhsBG,,G)D//))#..C\!__  3NrV   r  r  r  s     rT   test_two_d_array_reductionz&TestParfors.test_two_d_array_reduction  s-    		 		 		 	

9c"""""rV   c                 8    d }|                      |d           d S )Nc                     d}t          j        |t           j                  }t          j        g d                              |          }t          j        |           D ]}||z  }|S )Nr  )rU  r$  r  r  rJ  rK  )r   r9  r  r  r  r   r   r   r  r  r  r   s        rT   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NrV   r  r  r  s     rT   +test_two_d_array_reduction_with_float_sizesz7TestParfors.test_two_d_array_reduction_with_float_sizes  s-    	 	 	 	

9c"""""rV   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        rT   r  z>TestParfors.test_two_d_array_reduction_prod.<locals>.test_impl  sZ    C"'#rw///Gbl7+++C\!__  3NrV   r  r  r  s     rT   test_two_d_array_reduction_prodz+TestParfors.test_two_d_array_reduction_prod  s-    	 	 	 	

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

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

9a     rV   c                    d }t          j        dt          j        d                    }|                     |t	          j        |          f          }|                     |                    |           ||                     d S )Nc                     | j         S rX   r   r  s    rT   r  z8TestParfors.test_preparfor_datetime64.<locals>.test_impl  s	    7NrV   r   zdatetime64[ns])r   r  r!  r   r   r   r   r   )rQ   r  rx  r   s       rT   test_preparfor_datetime64z%TestParfors.test_preparfor_datetime64  s    	 	 	 HQ!12233&&y5<??2DEE++A..		!=====rV   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  )rm  r   r  r   Rr  r   s          rT   r  zITestParfors.test_no_hoisting_with_member_function_call.<locals>.test_impl  sn    
ACAYY  IIa  A1HCCs
JrV   r  )r   r   r  r  r  s     rT   *test_no_hoisting_with_member_function_callz6TestParfors.test_no_hoisting_with_member_function_call  s;    
	 
	 
	 	

9binnS1122222rV   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   r9  r  rm  s    rT   r  z8TestParfors.test_array_compare_scalar.<locals>.test_impl  s!    27+++A6MrV   Nr  r  s     rT   test_array_compare_scalarz%TestParfors.test_array_compare_scalar  s+    	 	 	 	

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

9a
>>>>>rV   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 r  )r   r  r   r  r   r   )r   r   datar  r   s        rT   r  z7TestParfors.test_prange_side_effects.<locals>.test_impl  s    8CFF"*555Dt99D\$''  A$Q\$'' ) )q'AaD.QKrV   r  r   r   r  )	r   r  floatr   r   r   r   r  r  )rQ   r  r   rf  s       rT   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rV   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  r]  r   r   )r   r   r   r   atupr   r   s       rT   r  z*TestParfors.test_tuple1.<locals>.test_impl*  sZ    DA\#a&&)) . .!Q$q')A--HrV   r   r  r+  s      rT   test_tuple1zTestParfors.test_tuple1)  :    	 	 	 IbMM

9a     rV   c                 `    d }t          j        d          }|                     ||           d S )Nc                     | j         }d}t          j        t          |                     D ]}| |xx         |d         |z   z  cc<   | S )Nr]  r   )r  r   r   r   r4  s       rT   r  z*TestParfors.test_tuple2.<locals>.test_impl5  sR    7DA\#a&&)) $ $!Q!#HrV   r   r  r+  s      rT   test_tuple2zTestParfors.test_tuple24  r7  rV   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  r]  r   r~   r   )r   r  r   r   r   r4  s       rT   r  z*TestParfors.test_tuple3.<locals>.test_impl@  sk    IbMM1%DA\#a&&)) 1 1!Q
T!W,q00HrV   r   r  r+  s      rT   test_tuple3zTestParfors.test_tuple3?  r7  rV   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   r]  )r   r   r   r   r   r   )r   antupr   r   s       rT   r  z/TestParfors.test_namedtuple1.<locals>.test_implK  sc    "!444EA\#a&&)) 6 6!ek1A55HrV   r   r  r+  s      rT   test_namedtuple1zTestParfors.test_namedtuple1J  r7  rV   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   rA  r   r   rD  s       rT   r  z/TestParfors.test_namedtuple2.<locals>.test_implW  sf    #O!1555EA\#a&&)) 6 6!ek1A55HrV   r   )r   r   r  r   )rQ   r  r   rD  s      @rT   test_namedtuple2zTestParfors.test_namedtuple2U  sV    $%68JKK	 	 	 	 	 IbMM

9a     rV   c                     t          ddg          }d }d } |t          j        d                    }|                     |||g           d S )NTestNamedTuple3rf  c                     d| j         d d <   d S )Nr~   rf  rz  s    rT   r  z/TestParfors.test_namedtuple3.<locals>.test_implf  s    ACFFFrV   c                 Z    t           j                            | j        |j                   d S rX   )r   r   r   rf  r   s     rT   r~  z.TestParfors.test_namedtuple3.<locals>.compareri  s$    J**1344444rV   r   rJ  r  )r   r   r9  r   )rQ   rH  r  r~  r   s        rT   test_namedtuple3zTestParfors.test_namedtuple3a  sp     %%7>>	 	 		5 	5 	5 Obhrll+++

9aXJ
?????rV   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 rX   rz   r   s     rT   r  z1TestParfors.test_inplace_binop.<locals>.test_implp  s    FAHrV   r   r  r   r  )r   r  r   r   r   r   r  r  rQ   r  rm  rl  s       rT   test_inplace_binopzTestParfors.test_inplace_binopo  s    	 	 	 IbMMBIbMMC

9a###i%*[3%G%G%*[3%G%G%IJ JKL	N 	N 	N 	N 	NrV   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   r9  uint64r  r   r   array_shapeindicesk_listr   r  s          rT   r  z0TestParfors.test_tuple_concat.<locals>.test_impl}  st    AAQ$Kh{ 2T 9")LLLGQT]F!! ! !1 q!tMrV   r   rM  r+  s      rT   test_tuple_concatzTestParfors.test_tuple_concat{  s@    	 	 	 HaV

9a     rV   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  rG   r   r   rS  rU  s          rT   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MrV   r   rM  r+  s      rT   $test_tuple_concat_with_reverse_slicez0TestParfors.test_tuple_concat_with_reverse_slice  s@    		 		 		 HaV

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

9a     rV   c                 `    d }t          j        d          }|                     ||           d S )Nc                     | dz  S )NrJ  rz   r6  s    rT   r  z3TestParfors.test_high_dimension1.<locals>.test_impl  s    s7NrV   )r   r   r   r   r      r  r+  s      rT   test_high_dimension1z TestParfors.test_high_dimension1  s;    	 	 	G'((

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

9bhrllB/////rV   c                 b    d }d}|                      |t          j        |          d           d S )Nc                 >    t          j        |          D ]}d| |<   | S r  ri  rk  s      rT   r  z=TestParfors.test_tuple_arg_not_whole_array.<locals>.test_impl  rm  rV   rn  r   r  r   r   r9  ro  s      rT   test_tuple_arg_not_whole_arrayz*TestParfors.test_tuple_arg_not_whole_array  s<    	 	 	 

9bhrllG44444rV   c                 `    d }d}|                      |t          j        |                     d S )Nc                 B    d}t          j        |          D ]}d| |<   | S )Nrn  r   ri  rk  s      rT   r  z6TestParfors.test_tuple_for_pndindex.<locals>.test_impl  s0    B^B''  !HrV   rn  rt  ro  s      rT   test_tuple_for_pndindexz#TestParfors.test_tuple_for_pndindex  s:    	 	 	
 

9bhrll+++++rV   c                 b    d }d}|                      |t          j        |          d           d S )Nc                 F    |df}t          j        |          D ]}d| |<   | S r  ri  )r   firstrl  r   s       rT   r  z5TestParfors.test_tuple_arg_literal.<locals>.test_impl  s4    B^B''  !HrV   rn  r   rt  ro  s      rT   test_tuple_arg_literalz"TestParfors.test_tuple_arg_literal  s<    	 	 	
 

9bhrllB/////rV   c                      d d d                          fd}t           t          d          fD ]} ||           d S )Nc                 >    t          j        |          D ]}d| |<   | S r  ri  rk  s      rT   r  z?TestParfors.test_tuple_of_literal_nonliteral.<locals>.test_impl  rm  rV   c                      || d          S )Nrs  rz   )r   r)  s     rT   rE  z:TestParfors.test_tuple_of_literal_nonliteral.<locals>.call  s    2a>>!rV   c                  *    t          j        d          S )Nr3  r   r9  rz   rV   rT   r  z>TestParfors.test_tuple_of_literal_nonliteral.<locals>.<lambda>  s    BHX.. rV   c                      |           }t                    } |             |          }                    |           d S rX   )r   assertPreciseEqual)	decf1f2gotrE  expected	get_inputrQ   r  s	       rT   r   z;TestParfors.test_tuple_of_literal_nonliteral.<locals>.check  sN    YBdB"YY[["%%C##Hc22222rV   Tr   r   )rQ   r   r  rE  r  r  r  s   `  @@@@rT    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	 	rV   c                 b    d }d}|                      |t          j        |          |           d S )Nc                 >    t          j        |          D ]}d| |<   | S r  ri  rk  s      rT   r  z0TestParfors.test_tuple_arg_1d.<locals>.test_impl  rm  rV   r   rt  ro  s      rT   test_tuple_arg_1dzTestParfors.test_tuple_arg_1d  s<    	 	 	 

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

9bhrll+++++rV   c                 ^    d }|                      |t          j        d          d           d S )Nc                 >    t          j        |          D ]}d| |<   | S r  ri  rk  s      rT   r  z4TestParfors.test_int_arg_pndindex.<locals>.test_impl  rm  rV   r3  r  rt  r  s     rT   test_int_arg_pndindexz!TestParfors.test_int_arg_pndindex  s9    	 	 	 	

9bhx00!44444rV   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   rz  )ur   evenr  rw  s        rT   issue7854_procz=TestParfors.test_prange_unknown_call1.<locals>.issue7854_proc  s\    D1HqLA-14!8Q?? * *AE1H+/!Q$* *rV   c                     t          j        d|dz
            D ]} | |d|           t          j        d|dz
            D ]} | |d|           | S r  r   r   )r  r  r   r  s      rT   r  z8TestParfors.test_prange_unknown_call1.<locals>.test_impl  sx    \!TAX.. . .q!Q----\!TAX.. . .q!Q----HrV   r  r   r   )
r?   r   r9  r   r  r   r  r   r   r   )rQ   r  r  r  cptypesr  s        @rT   test_prange_unknown_call1z%TestParfors.test_prange_unknown_call1  s    		* 	* 
		*	 	 	 	 	 HdD\""=CCaC(%+6i991===

9a&&&&&rV   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   rw  s       rT   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.HrV   r  r   r   	r   r9  r   r  r   r  r   r   r   )rQ   r  r  r  r  s        rT   test_prange_index_calc1z#TestParfors.test_prange_index_calc1  s    	 	 	 HdD\""=CCaC(%+6i991===

9a&&&&&rV   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  r.  r  )r   r   r  r   rw  s        rT   r  z9TestParfors.test_prange_reverse_order1.<locals>.test_impl&  s    \$'' * *t * *A1gkAadGG*\$''    t    AAadGG T7QtW$$rV   r   r   r   r  rQ   r  r  r   r   r  s         rT   test_prange_reverse_order1z&TestParfors.test_prange_reverse_order1#  s    	% 	% 	% HdD\""HdD\""=CCaC(%-33Q3*?Mi991===

9aD)))))rV   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       rT   r  z@TestParfors.test_prange_parfor_index_then_not.<locals>.test_impl9  sX    A\$''  !\$''  QqT	HrV   r   r   r  )rQ   r  r  r   r  s        rT   !test_prange_parfor_index_then_notz-TestParfors.test_prange_parfor_index_then_not6  sx    	 	 	 HTNN=#U[1i991===

9a&&&&&rV   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        rT   r  zJTestParfors.test_prange_parfor_index_const_tuple_fusion.<locals>.test_implJ  si    C\$'' " "3q6z!\$'' % %qtc!f}$JrV   r   r   )r   r9  r   r   r  r   
containersUniTupler  r   r   r   r  s         rT   +test_prange_parfor_index_const_tuple_fusionz7TestParfors.test_prange_parfor_index_const_tuple_fusionG  s    	 	 	 HTNN!HH=##,,U]DAA: 	i991===

9aD)))))rV   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       rT   r  zITestParfors.test_prange_non_parfor_index_then_opposite.<locals>.test_impl^  sl    \$''  t!\$''  !aDDDAaDLDDDHrV   r   r   r  r  s         rT   *test_prange_non_parfor_index_then_oppositez6TestParfors.test_prange_non_parfor_index_then_opposite[  s    	 	 	 HTNNHTNN=#U]111%5u{Ci991===

9aD)))))rV   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      rT   r  z3TestParfors.test_prange_optional.<locals>.test_implo  s1    AYY ! !# CF! !rV   r   c                     | |k    S rX   rz   r   rf  s     rT   r  z2TestParfors.test_prange_optional.<locals>.<lambda>w  s
    AF rV   r  rL  rX   )r   r  r   r   r   r   rv  rQ   r  r  s      rT   test_prange_optionalz TestParfors.test_prange_optionaln  s    	! 	! 	! 	!
 gbkk

9c4')z'E':':'< 	 	= 	= 	= 	D)))))rV   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   rz   rz  s    rT   r  z8TestParfors.test_untraced_value_tuple.<locals>.test_impl|  s    AQ4KrV   r  r  r	  s      rT   test_untraced_value_tuplez%TestParfors.test_untraced_value_tuplez  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   rz   rz  s    rT   r  zBTestParfors.test_recursive_untraced_value_tuple.<locals>.test_impl  s    AQ47NrV   r  r  r	  s      rT   #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arr3rw  totaln3r   s              rT   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<rV   r   r  r   r   )r   r  r  r   r   r   r  r   )rQ   r  r  r  s       rT   test_untraced_value_parforz&TestParfors.test_untraced_value_parfor  s{    	  	  	   {5;3//2i55q999i"(+++

9c"""""rV   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   rJ  r   s      rT   r  z;TestParfors.test_setitem_2d_one_replaced.<locals>.test_impl  sR    E171:&&   A%(
HrV   )r  r   rt  r  s     rT   test_setitem_2d_one_replacedz(TestParfors.test_setitem_2d_one_replaced  s7    	 	 	 	

9bhv../////rV   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invr$  s        rT   r  z7TestParfors.test_1array_control_flow.<locals>.test_impl  s[    )CH%%C .zz"*--- ##h#'l>!rV   r  TFr  r  s      rT   test_1array_control_flowz$TestParfors.test_1array_control_flow  sn    	" 	" 	" inn

9c4///

9c4...

9c5%00000rV   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         rT   r  z9TestParfors.test_2array_1_control_flow.<locals>.test_impl  sT    9SX&&D9Q1--D %4j4!8n:rV   r  r   TFr  r  s      rT   test_2array_1_control_flowz&TestParfors.test_2array_1_control_flow  sV    	 	 	 inn

9c2t,,,

9c2u-----rV   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          rT   r  z9TestParfors.test_2array_2_control_flow.<locals>.test_impl  sj    9SX&&D9Q1--D &DzDzD1H~D1H~$;rV   r  r   TFr  r  s      rT   test_2array_2_control_flowz&TestParfors.test_2array_2_control_flow  sV    		 		 		 inn

9c2t,,,

9c2u-----rV   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   r9  r  r   r   )r   rcr   rw  s        rT   r  z-TestParfors.test_issue8515.<locals>.test_impl  s    "'***A"'***AAYY  q  AaDDDAIDDDD AYY ' '66taAh!QRR5LrV   re  r   )r   r   r   r   r  r  s     rT   test_issue8515zTestParfors.test_issue8515  sQ    	 	 	 	

9b!!!i%+AA1EEEEErV   c                 :    d }|                      |dd           d S )Nc                 6   d}d}t          j        ||f          }t          |          D ]n}t          |          D ]\}t          j        |          }|d         }t          j        |          }	t	          | |          D ]}
d|	|
<   |	d         }||z   |||f<   ]o|S )Nr  r  r   r   )r   r  r   r  r   )i1i2r  r`  r   rf  r   r  r  p2r   rw  s               rT   r  z-TestParfors.test_issue9029.<locals>.test_impl  s    AA!AA 1XX 
# 
#q 	# 	#AWQZZFq	A!B#B^^ " " !11AUAacFF	# HrV   r   r  r  r  s     rT   test_issue9029zTestParfors.test_issue9029  s/    	 	 	, 	

9a#####rV   c                     d }|                      |dd           |                     t          |t          j        t          j        f          d           d S )Nc                     t          j        d          }t          j        |          }t          j        d          }t	          t          | |                    }||z   |z   S Nr  )r   r  ru  ceilintr  )r   r   rm  rl  r  s        rT   r  z:TestParfors.test_fusion_no_side_effects.<locals>.test_impl	  sJ    A	!AAC1IIAq519rV   g@g333333@r   )r   r   r   r   r  r  s     rT   test_fusion_no_side_effectsz'TestParfors.test_fusion_no_side_effects	  sY    	 	 	 	

9c3'''i%-1OPPRSTTTTTrV   c                     t          d          d             }|                      |d          |                    d                     d S )NTr   c                 P    d}t          d           t          |           D ]}|}|S r  r   r   )r   r  r   s      rT   def_in_loopzCTestParfors.test_issue9256_lower_sroa_conflict.<locals>.def_in_loop	  s6    AAAYY  HrV   r   r   r   py_func)rQ   r  s     rT   "test_issue9256_lower_sroa_conflictz.TestParfors.test_issue9256_lower_sroa_conflict	  s[    	t				 	 
		 	R+*=*=b*A*ABBBBBrV   c                     d } |d          }|                      |  t          d          |          d                     |                      |  t          d          |          d                     d S )Nc                 f    | }t          d           t          |           D ]	}|r| dz   }
||dk    fS Nr   r  r   r  )r   r  _ir  s       rT   r  zLTestParfors.test_issue9256_lower_sroa_conflict_variant1.<locals>.def_in_loop*	  sI    AAQii   AAa!e8OrV   r  Fr   Tr   r   rQ   r  r  s      rT   +test_issue9256_lower_sroa_conflict_variant1z7TestParfors.test_issue9256_lower_sroa_conflict_variant1)	  s    	 	 	 ;q>>#D#74#7#7#7#D#DQ#G#GHHH#C#64#6#6#6{#C#CA#F#FGGGGGrV   c                     d } |d          }|                      |  t          d          |          d                     |                      |  t          d          |          d                     d S )Nc                     | }t          d           t          |           D ]}|rt          |           D ]}| dz   }||dk    fS r  )r   r   r   )r   r  r  _jr  s        rT   r  zLTestParfors.test_issue9256_lower_sroa_conflict_variant2.<locals>.def_in_loop7	  s`    AAQii " " "#Ahh " "Ea!e8OrV   r  Fr   Tr  r   s      rT   +test_issue9256_lower_sroa_conflict_variant2z7TestParfors.test_issue9256_lower_sroa_conflict_variant26	  s    	 	 	 ;q>>#D#74#7#7#7#D#DQ#G#GHHH#C#64#6#6#6{#C#CA#F#FGGGGGrV   c                    t           j        ddg}	 t          j        |i t          j        dddt          j        d           d S # t          j        $ r+}d|j         }| 	                    |           Y d }~d S d }~ww xY w)	N-mz"numba.tests.parfor_iss9490_usecase1)PYTHONHASHSEEDNUMBA_NUM_THREADSzutf-8)envstderrencodingzsubprocess failed with output:
)r   )
sys
executablesubpcheck_outputosenvironSTDOUTCalledProcessErroroutputfail)rQ   cmdr  r   s       rT   "test_issue9490_non_det_ssa_problemz.TestParfors.test_issue9490_non_det_ssa_problemD	  s     N0
	c (B"* (B:==@(B (B (B &*['.	0 0 0 0 0 0
 & 	 	 	?QX??CII#I	s   3A B  A;;B N)Tru   rL   rv   rR  rt  r{  r  r  r  r  r  r  r  r  r  r  r  r  r9   r  r  r  r;   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r&  r,  r1  r6  r:  r=  rB  rF  rL  rP  rY  r\  rb  rf  rp  ru  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  rz   rV   rT   ro  ro  #  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($ $ $6U U U	C 	C 	CH H HH H H "  #" \  rV   ro  c                        e Zd Zd Zd Zd ZdS )TestParforsLeaksc                 N     | j         |g|R  \  }} | j        |||g|R i | d S rX   r   r   s         rT   r   zTestParforsLeaks.checkZ	  M    ((7$777v$$VUFLTLLLVLLLLLrV   c                     d }t          j        d                              t           j                  }|                     ||           d S )Nc                 *    |                                  S rX   r_  )r  s    rT   r  z2TestParforsLeaks.test_reduction.<locals>.test_impl`	  s    7799rV   r   r   r  r  r  r   r  s      rT   test_reductionzTestParforsLeaks.test_reduction^	  sJ    	 	 	 imm""2:..

9c"""""rV   c                     d }t          j        d                              t           j                  }|                     ||           d S )Nc                 z    d}d}t          | j                  D ]}|| |         z  }|d| |         dz   z  z  }||z  S )Nr  rU  r   )r   r  )r  r   r   r   s       rT   r  z@TestParforsLeaks.test_multiple_reduction_vars.<locals>.test_implh	  sT    AACH%% ' 'SVR3q6A:&&q5LrV   r   r   r  s      rT   test_multiple_reduction_varsz-TestParforsLeaks.test_multiple_reduction_varsf	  sJ    	 	 	 imm""2:..

9c"""""rV   N)ru   rL   rv   r   r!  r$  rz   rV   rT   r  r  X	  sD        M M M# # #
# 
# 
# 
# 
#rV   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      rT   r  z6TestParforsSlice.test_parfor_slice1.<locals>.test_implw	  s2    7DQ!AaC%1QqsU8#AHrV   r   r   r   r  r  s     rT   test_parfor_slice1z#TestParforsSlice.test_parfor_slice1v	  s5    	 	 	
 	

9bgbkk*****rV   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   r<  r   r   s       rT   r  z6TestParforsSlice.test_parfor_slice2.<locals>.test_impl	  s.    7DQ!AaC%1QqS6!AHrV   r   r  Tr   do not match	r   r   r  r  r  r   r   r  r  r	  s      rT   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*  r0  s       rT   r  z6TestParforsSlice.test_parfor_slice3.<locals>.test_impl	  sD    GEQq!AaC%!A#+1Q3qs7+AHrV   r  r  r,  r  s     rT   test_parfor_slice3z#TestParforsSlice.test_parfor_slice3	  5    	 	 	
 	

9bgenn-----rV   c                 \    d }|                      |t          j        d                     d S )Nc                 Z    | j         \  }}| d d d|dz
  f         | d d d|f         z   }|S r  r*  r0  s       rT   r  z6TestParforsSlice.test_parfor_slice4.<locals>.test_impl	  s@    GEQq!!!AacE'
Qqqq1uX%AHrV   r6  r,  r  s     rT   test_parfor_slice4z#TestParforsSlice.test_parfor_slice4	  r8  rV   c                 \    d }|                      |t          j        d                     d S )Nc                 Z    | j         \  }}| d|dz
  d d f         | d|d d f         z   }|S r  r*  r0  s       rT   r  z6TestParforsSlice.test_parfor_slice5.<locals>.test_impl	  s@    GEQq!AaC%'
Qqs111uX%AHrV   r6  r,  r  s     rT   test_parfor_slice5z#TestParforsSlice.test_parfor_slice5	  r8  rV   c                 \    d }|                      |t          j        d                     d S )Nc                 `    |                                  }| dd d f         |d d df         z   }|S r  	transposer   r   r  s      rT   r  z6TestParforsSlice.test_parfor_slice6.<locals>.test_impl	  s5    A!AAA#111Q3AHrV   r6  r,  r  s     rT   test_parfor_slice6z#TestParforsSlice.test_parfor_slice6	  r8  rV   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  rA  rC  s      rT   r  z6TestParforsSlice.test_parfor_slice7.<locals>.test_impl	  s5    A!AAA#1QQQ3AHrV   ra  Tr   r  r1  r2  r	  s      rT   test_parfor_slice7z#TestParforsSlice.test_parfor_slice7	  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  rB  r0  s       rT   r  z6TestParforsSlice.test_parfor_slice8.<locals>.test_impl	  sD    GEQqA1Q3qs7Aac!A#gJHrV   r  ra  r   r   r  r  r  s     rT   test_parfor_slice8z#TestParforsSlice.test_parfor_slice8	  C    	 	 	 	

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

9bimm33E::;;;;;rV   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dd|f         |dd|f<   |S r  rJ  r0  s       rT   r  z7TestParforsSlice.test_parfor_slice10.<locals>.test_impl	  s<    GEQqA1Q3xAa!eHHrV   r  ra  rK  r  s     rT   test_parfor_slice10z$TestParforsSlice.test_parfor_slice10	  rM  rV   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   r<  r   r  r   s        rT   r  z7TestParforsSlice.test_parfor_slice11.<locals>.test_impl	  sJ    gGQqA111Qqs7Aaaa!A#gJHrV      )r  r  r  rK  r  s     rT   test_parfor_slice11z$TestParforsSlice.test_parfor_slice11	  sC    	 	 	 	

9bimm33G<<=====rV   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dd df         |dddf<   |S )Nr   r   rG   rV  r0  s       rT   r  z7TestParforsSlice.test_parfor_slice12.<locals>.test_impl	  s<    GEQqA!CRC%Aa"fIHrV   rx  r  rK  r  s     rT   test_parfor_slice12z$TestParforsSlice.test_parfor_slice12	  C    	 	 	 	

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

9bimm33E::;;;;;rV   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dddf         |dd df<   |S )Nr   r  r   rG   rV  r0  s       rT   r  z7TestParforsSlice.test_parfor_slice14.<locals>.test_impl	  s<    GEQqA2a4yAaeHHrV   rx  r  rK  r  s     rT   test_parfor_slice14z$TestParforsSlice.test_parfor_slice14	  r]  rV   c                     d }|                      |t          j        d                              d                     d S )Nc                 p    | j         \  }}|                                 }| dddf         |d|dz
   d f<   |S )Nr   rc  r  r   rV  r0  s       rT   r  z7TestParforsSlice.test_parfor_slice15.<locals>.test_impl	  sB    GEQqAQr!tV9Aa!A#iLHrV   rx  r  rK  r  s     rT   test_parfor_slice15z$TestParforsSlice.test_parfor_slice15	  r]  rV   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      rT   r  z7TestParforsSlice.test_parfor_slice16.<locals>.test_impl

  s>    7ag%%%%AacFAa1gJq5LrV   r      Nr   )	r   r   r  r9  r   r  r  r   r   rQ   r  r   s      rT   test_parfor_slice16z$TestParforsSlice.test_parfor_slice16
  s    	 	 	 	

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

9b"'"++.....rV   c                 6    d }|                      |           d S )Nc                  r    t          j        d          } t          j        dd          | dd<   | d         }|S )Nr   r   r]  r   rk  r  )r   r9  r  )r   rf  s     rT   r  z7TestParforsSlice.test_parfor_slice18.<locals>.test_impl
  s4    AYq!__AacF!AHrV   r  r  s     rT   test_parfor_slice18z$TestParforsSlice.test_parfor_slice18
  s+    	 	 	 	

9rV   c                 \    d }|                      |t          j        d                     d S )Nc                 *    | d dxx         dz  cc<   | S r  rz   r%  s    rT   r  z7TestParforsSlice.test_parfor_slice19.<locals>.test_impl)
  s     bqbEEEQJEEEHrV   r   r,  r  s     rT   test_parfor_slice19z$TestParforsSlice.test_parfor_slice19'
  5    	 	 	 	

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

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

9b"%%%%%rV   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   r9  r   )r~  r  r   r   s       rT   r  z7TestParforsSlice.test_parfor_slice22.<locals>.test_implD
  s@    AAYY  R2YHrV   )r   r]  r  )r   r9  r  r   r  s       rT   test_parfor_slice22z$TestParforsSlice.test_parfor_slice22C
  sK    	 	 	 XfXa[[

9b"%%%%%rV   c                 \    d }|                      |t          j        d                     d S )Nc                     d| d d<   | S )Nr   r   rz   r6  s    rT   r  z7TestParforsSlice.test_parfor_slice23.<locals>.test_implP
  s    AbqbEHrV   r   r,  r  s     rT   test_parfor_slice23z$TestParforsSlice.test_parfor_slice23N
  rx  rV   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }||d          }|d t          |                   }|S rX   rp  r<  rx  r   r  r  s        rT   r  z7TestParforsSlice.test_parfor_slice24.<locals>.test_implW
  s4    A!""A'3q66'
AHrV   re  r   r   r   r   r  rQ   r  r   s      rT   test_parfor_slice24z$TestParforsSlice.test_parfor_slice24V
  W    	 	 	 sB 	6 	6AJJy"bgbkk15555	6 	6rV   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }|d |         }|d t          |                   }|S rX   rp  r  s        rT   r  z7TestParforsSlice.test_parfor_slice25.<locals>.test_impla
  s4    A"1"A'3q66'
AHrV   r  re  r   r  r  s      rT   test_parfor_slice25z$TestParforsSlice.test_parfor_slice25`
  r  rV   c                 \    d }|                      |t          j        d                     d S )Nc                 f    | j         \  }|                                 }| dd         ||dz
   d <   |S )Nrc  r  r   rV  r+  s      rT   r  z7TestParforsSlice.test_parfor_slice26.<locals>.test_implk
  s8    7DQA2a4A!fggJHrV   r  r   r   r  r  s     rT   test_parfor_slice26z$TestParforsSlice.test_parfor_slice26j
  s5    	 	 	 	

9bill+++++rV   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       rT   r  z7TestParforsSlice.test_parfor_slice27.<locals>.test_implv
  sW    LAGAJ'' . .Q4199 A%L .}}-F1rV   r  r  r  s     rT   test_parfor_slice27z$TestParforsSlice.test_parfor_slice27s
  s5    
	 
	 
	 	

9bill+++++rV   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   rG   r[  c                     t          j        | dz                                | df          }d}t          j        |           D ]!}|||f                                         z  }"|S Nr  r   )r   r  r  r   r   rv  )r   rm  rf  r   tss       rT   r  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl
  se    Ia!e$$,,aV44a ( (A1b5'AArV   r   r  c                     d}t          j        | j        d                   D ]!}|| |f                                         z  }"|S r  )r   r   r  rv  )rm  rf  r   r  s      rT   r  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl
  sH    agaj11 ( (A1b5'AArV   )slicer   r   r  r  )rQ   r  r   rm  r  s       @rT   $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!$$$$+	% 	%rV   N) ru   rL   rv   r-  r3  r7  r;  r>  rD  rG  r;   rL  rP  rS  rX  r\  r`  rd  rg  rm  rq  rt  rw  r{  r  r  r  r  r  r  r  r  rz   rV   rT   r&  r&  s	  s       + + += = =. . .. . .. . .. . .= = = ; ; ]; < < ]< ; ; ];> > >< < << < << < << < < ; ; ];/ / /  + + +6 6 6& & &	& 	& 	&+ + +6 6 66 6 6, , ,, , ,"% % % % %rV   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 rz   rz   )r   r   s     rT   r   zMTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<listcomp>
  s    0001000rV   c                     | |z   S rX   rz   r  s     rT   r  zKTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<lambda>
  s
    QqS rV   )r  r   r  r  r   r   r   )r   r   r   r  r   s        rT   r  z9TestParforsOptions.test_parfor_options.<locals>.test_impl
  s    
A

A00eAhh00011AAIAbqbEAYY # #tad{!..!Q///rV   r   r   F)fusionr  )r  comprehensionr~   )r  r  setitemr  )r  r  r  r   r  )r  r  r  r   	reductionr   )r  r  r  r   r  r  r   )r   r   r  r   r  r   r   rl  s      rT   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	; 	; 	; 	; 	;rV   N)ru   rL   rv   r  rz   rV   rT   r  r  
  s#         ;  ;  ;  ;  ;rV   r  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  rz   r+  s      rT   r  z:TestParforsBitMask.test_parfor_bitmask1.<locals>.test_impl
  s    AAAaDHrV   r   r~   r  r  s     rT   test_parfor_bitmask1z'TestParforsBitMask.test_parfor_bitmask1
  s7    	 	 	
 	

9bimmQ/////rV   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                     d| |<   | S r  rz   r   s     rT   r  z:TestParforsBitMask.test_parfor_bitmask2.<locals>.test_impl
      AaDHrV   r   r~   r  rN  s       rT   test_parfor_bitmask2z'TestParforsBitMask.test_parfor_bitmask2
  E    	 	 	 IbMME

9a#####rV   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                     | |         | |<   | S rX   rz   r   s     rT   r  z:TestParforsBitMask.test_parfor_bitmask3.<locals>.test_impl
  s    Q4AaDHrV   r   r~   r  rN  s       rT   test_parfor_bitmask3z'TestParforsBitMask.test_parfor_bitmask3
  r  rV   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 "    d| z  |         | |<   | S rt  rz   r   s     rT   r  z:TestParforsBitMask.test_parfor_bitmask4.<locals>.test_impl
  s    E1:AaDHrV   r   r~   r  rN  s       rT   test_parfor_bitmask4z'TestParforsBitMask.test_parfor_bitmask4
  r  rV   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 .    | |         | |         z  | |<   | S rX   rz   r   s     rT   r  z:TestParforsBitMask.test_parfor_bitmask5.<locals>.test_impl
  s    Q4!A$;AaDHrV   r   r~   r  rN  s       rT   test_parfor_bitmask5z'TestParforsBitMask.test_parfor_bitmask5
  r  rV   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 rX   rz   rC  s      rT   r  z:TestParforsBitMask.test_parfor_bitmask6.<locals>.test_impl
  r  rV   r   r~   r  )
r   r  r9  rv  r  r  r   r   r  r  )rQ   r  r   r   r  r
  s         rT   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)	ru   rL   rv   r  r  r  r  r  r  rz   rV   rT   r  r  
  ss        0 0 0$ $ $$ $ $$ $ $$ $ $M M M M MrV   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 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 r  )r   r  r   r  )r  r   s     rT   r   z9TestParforsMisc.test_no_warn_if_cache_set.<locals>.pyfunc  sD    '#,,CCH%%  A!JrV   T)r   cacherecordalwaysignore	typeguard)actionmodulez.*TBB_INTERFACE_VERSION.*znumba\.np\.ufunc\.parallel.*)r  messagecategoryr  r   c                 &    g | ]}|j         j        S rz   )r   has_dynamic_globals)r   r   s     rT   r   z=TestParforsMisc.test_no_warn_if_cache_set.<locals>.<listcomp>  s3     E E E#'  $|? E E ErV   F)r   warningscatch_warningssimplefilterfilterwarningsr   r   NumbaWarningr   r   r   r  )rQ   r   r   raised_warningsr  s        rT   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   r]  r   rk  za[3]:r  )r   r9  r  printrz  s    rT   r   zITestParforsMisc.test_statement_reordering_respects_aliasing.<locals>.impl#  sS    AYq!__AacF'1Q4   '1Q4   HrV   rz   z	a[3]: 2.0)r   r2   r   getvaluer7  r   )rQ   r   r   stdoutlines        rT   +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 rX   )r   isinfr  s    rT   r  z;TestParforsMisc.test_parfor_ufunc_typing.<locals>.test_impl1  s    8A;;rV   r  Tr   )
r   r  r  r   r   r  r  sequential_parfor_loweringr   assert_array_equal)rQ   r  rx  r   old_seq_flags        rT   test_parfor_ufunc_typingz(TestParforsMisc.test_parfor_ufunc_typing0  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       rT   r  z6TestParforsMisc.test_init_block_dce.<locals>.test_implA  s`    C++CM ,,...E\!__  s1vq>!rV   rz   r   )r   r  r  s     rT   test_init_block_dcez#TestParforsMisc.test_init_block_dce?  s:    	" 	" 	" 	,Y;;Q?????rV   c                 6    d }|                      |           d S )Nc                  b    d} t          d          D ]}| dz  } t          j        | f          }|S )Nr   r  r   r   r   r9  )r  rH   r/  s      rT   r  zBTestParforsMisc.test_alias_analysis_for_parfor1.<locals>.test_implM  s=    C1XX  q8SF##DKrV   r  r  s     rT   test_alias_analysis_for_parfor1z/TestParforsMisc.test_alias_analysis_for_parfor1L  s+    	 	 	 	

9rV   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 rX   )r/   r  rZ   s    rT   r  z_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.__init__b  s    %d+++++rV   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                  rX   )r   LoweringError)rQ   otherr  s     rT   
differencezzTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_pass.<locals>.Broken.differenceq  s    *0*>z*J*J$JrV   N)ru   rL   rv   r  r  s   rT   Brokenr  o  s5        !K !K !K !K !K !K !KrV   r  T)r  r  r  r  r   r   r  r  r  r   races)rQ   r  blkr  r  r  s        rT   run_passz_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_passe  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   rV   N)ru   rL   rv   _namer  r  r  s   rT   BreakParforsr  ^  sB        #E, , ,             rV   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 rX   )r-   define_nopython_pipeliner  add_pass_afterr0   finalize)rQ   pmr  s     rT   define_pipelineszoTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParforsCompiler.define_pipelinesz  s?    '@LL!!,???trV   N)ru   rL   rv   r  )r  s   rT   BreakParforsCompilerr
  x  s.              rV   r  )r   pipeline_classc                  8    d} t          d          D ]}| dz  } | S r  r  )r   rH   s     rT   foozMTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.foo  s,    AAYY  QHrV   )r.   r/   r,   r   assertFalser   r  r  r  r  r   r  r   r  r  )rQ   r  r  r
  r  r  s       @@rT   0test_no_state_change_in_gufunc_lowering_on_errorz@TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_errorW  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ru   rL   rv   rz   rV   rT   	DummyTyper            DrV   r  my_dummyc                       e Zd ZdS ).TestParforsMisc.test_issue_5098.<locals>.DummyNr  rz   rV   rT   Dummyr    r  rV   r   c                     S rX   rz   )valr  
dummy_types     rT   typeof_Dummyz5TestParforsMisc.test_issue_5098.<locals>.typeof_Dummy  s	    rV   c                 N    t          |j                                                  S rX   )r    contextget_dummy_value)typobjr  s      rT   unbox_indexz4TestParforsMisc.test_issue_5098.<locals>.unbox_index  s    qy88::;;;rV   method1r   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 rX   )r   r   r'  r  )r   fr  s      rT   bazzPTestParforsMisc.test_issue_5098.<locals>._get_method1.<locals>._foo.<locals>.baz  s/    A%'VAbhqkkN1Q44KrV   r   r   r  )r)  r  r   r1  length
output_arrr   s          rT   _foozCTestParforsMisc.test_issue_5098.<locals>._get_method1.<locals>._foo  s         
 SXfBJ???
 6 6A$'CA$5$5JqMM
++ 7 7AqMMMSSQ%6%66MMMM!!rV   rz   )r)  r  r   r4  s       rT   _get_method1z5TestParforsMisc.test_issue_5098.<locals>._get_method1  s    " " " KrV   c                 *    |                                  S rX   r  )r  s    rT   barz,TestParforsMisc.test_issue_5098.<locals>.bar  s    6688OrV   c                 `    |                      t          j        g dg dg                    S )NrU  r$  r  )r  rJ  rK  )r+  r   r  )r  r7  s    rT   test1z.TestParforsMisc.test_issue_5098.<locals>.test1  s.    99RX&HII3OOOrV   )r   Opaquer   r!   OpaqueModelobjectr   registerr   r   r   r   r  r  r  r  )
rQ   r  r   r$  r*  r5  r:  
save_stater7  r#  s
           @@rT   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 )	NTr   c                 H    d}d}t          d          D ]}|||          z  }|S )N)r   r   r  r  r   r   r  )idxbig_tuprG  r   s       rT   oversize_tuplezMTestParforsMisc.test_oversized_tuple_as_arg_to_kernel.<locals>.oversize_tuple  s6    GABZZ " "WS\!HrV   NUMBA_PARFOR_MAX_TUPLE_SIZE3r   zUse of a tuplezin a parallel region)r   r4   r  r   rj  r  r  r   )rQ   rE  r
  errstrs       rT   %test_oversized_tuple_as_arg_to_kernelz5TestParforsMisc.test_oversized_tuple_as_arg_to_kernel  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dimsrf  r   s          rT   	ndvi_njitz1TestParforsMisc.test_issue5167.<locals>.ndvi_njit  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 NrV   )r  r  rU  g     @)lowr  r  )r   r  uniformr   )rQ   rS  
tile_shapearray1array2s        rT   test_issue5167zTestParforsMisc.test_issue5167  sl    	 	 	 
""sz"JJ""sz"JJ

9ff-----rV   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 rL  )r   r9  r  r  r   r   )r   r  	dist_argsr  r   rw  r  s          rT   
reproducerz2TestParforsMisc.test_issue5065.<locals>.reproducer  s    Xqwqz171:6bjIIIFAGAJ'' % %q1uagaj11 % %AQqT1Q44)444A#$F1a4L#$F1a4LL% MrV   c                     d}t          | j        d                   D ]}|| |         ||         z
  dz  z  }t          j        |          S )Nr  r   r   )r   r  r   rW  )r   rf  r  r   s       rT   	euclideanz1TestParforsMisc.test_issue5065.<locals>.euclidean  sO    F171:&& - -1Q4!A$;1,,76??"rV   )r~   r   r  Tr   rz   )r   r   r  r   r   r  )rQ   r]  r_  r   r  r  s         rT   test_issue5065zTestParforsMisc.test_issue5065  s    	 	 	 
	# 	# 
	# I&))-!dD!!!*--affhh	"EE:affhh	"55

""311111rV   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      rT   test_numba_parallelz;TestParforsMisc.test_issue5001.<locals>.test_numba_parallel  sK    S3w<<'FCLL)) , ,
OOq		MrV   r  2   )r   r  r   )rQ   rd  rc  s      rT   test_issue5001zTestParforsMisc.test_issue5001  sH    	 	 	 8C==".

&00000rV   c                 ~    t           d             t          d          fd            } |dgfdz             d S )Nc                     d S rX   rz   )gridss    rT   r  z+TestParforsMisc.test_issue3169.<locals>.foo      DrV   Tr   c                 B    t          d          D ]} |            d S r  r  )ri  r   r  s     rT   r7  z+TestParforsMisc.test_issue3169.<locals>.bar  s1    AYY  E



 rV   r   r   r  )rQ   r7  r  s     @rT   test_issue3169zTestParforsMisc.test_issue3169  sh    		 	 
	 
t				 	 	 	 
		
 	aSFQJrV   c                     t          dd          }fd}t          d          d              |dd          }|                     ||           d S )	Nmytyper   c                 N    t          d          D ]} ||            | j        S rs  )r   r   )mydatar   inners     rT   outerz-TestParforsMisc.test_issue4846.<locals>.outer"  s4    AYY ! !a    8OrV   T)nogilc                 *    | |j         f}| |j        f}d S rX   r   )r   rp  r0  r  s       rT   rq  z-TestParforsMisc.test_issue4846.<locals>.inner'  s    FHAFHAAArV   r   r   )r   r   r   )rQ   rn  rr  rp  rq  s       @rT   test_issue4846zTestParforsMisc.test_issue4846  s     Hj11	 	 	 	 	
 
D				 	 
		 #%%%

5&!!!!!rV   c                 6    d }|                      |           d S )Nc                  b    d} d}t          t          |                     D ]}|| |         z  }|S )Nr  r   r   r   )r   r   r   s      rT   test1bz.TestParforsMisc.test_issue3748.<locals>.test1b2  s;    AACFF^^  QqT	HrV   r  )rQ   ry  s     rT   test_issue3748zTestParforsMisc.test_issue37480  s+    	 	 	 	

6rV   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   rf  s       rT   parallel_testz5TestParforsMisc.test_issue5277.<locals>.parallel_test=  sU    DG__ , ,Q , ,A !C!CF1II,JrV   r3  r   )r   r9  r  r   )rQ   r}  r  r  s       rT   test_issue5277zTestParforsMisc.test_issue5277;  sH    	 	 	 ht3'''

=$,,,,,rV   c                     t          d          d             }t          j        d          }d}t          j        d          }|                      ||||          |                    |||                     d S )NTr   c                 j    t          d          D ]}t          d          D ]	}d|||f<   
|r|dz  }|S r  r   r   )r   methodr  r   rw  s        rT   r  z5TestParforsMisc.test_issue5570_ssa_races.<locals>.fooI  sV    AYY " "q " "A !C1II" qJrV   )r~   r~   9   r>  )r   r   r9  r  r  )rQ   r  r   r  r  s        rT   test_issue5570_ssa_racesz(TestParforsMisc.test_issue5570_ssa_racesH  s    	t				 	 
		 huoohvCVS!!KKVS))	
 	
 	
 	
 	
rV   c                    t          d          d             }t          j                            d           t          j                            d          }|                      ||          |                    |                     d S )NTr   c                 r    | }t          dd          D ]}||d d d d f         }t          j        |          S )Nr   r   )r   r   r  )r   packager  z_stacks       rT   find_maxima_3D_jitzDTestParforsMisc.test_issue6095_numpy_max.<locals>.find_maxima_3D_jit\  sF    Gq" / /!%AAA+.6'??"rV   r   )r   r   r   )r   r   r  r  r  r  )rQ   r  r   s      rT   test_issue6095_numpy_maxz(TestParforsMisc.test_issue6095_numpy_max[  s    	t				# 	# 
		# 		qy--t$$&&t,,	
 	
 	
 	
 	
rV   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        rT   r  z3TestParforsMisc.test_issue5942_1.<locals>.test_implm  sm    B1Aq		 & &$&tQQQwKaaa a   A%    NrV   r  r   r   )r   r9  r  r   )rQ   r  r  r   r  r  s         rT   test_issue5942_1z TestParforsMisc.test_issue5942_1j  sm    	 	 	 (Aq628444(Aq628444

9b'*****rV   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   r9  r  r   r   )r  r   r  r  r  r   s         rT   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%    NrV   r  r   r  )rQ   r  r  r   s       rT   test_issue5942_2z TestParforsMisc.test_issue5942_2}  s9    
	 
	 
	 

9a#####rV   c                     t          d          d             }t          j        g dg dg          }|                      ||          |                    |                     d S )NTr   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   rG   )r   r  r   r  r  r  rR  norm)r  r   r  trr   dist_ts         rT   r0  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HrV   )r  r  r  )r  r  rU  )r   r   r  r  r  )rQ   r0  r  s      rT   test_issue6102zTestParforsMisc.test_issue6102  su     
t			
	 
	 
	
	 HlllLLL122!aiill33333rV   c                 6    d }|                      |           d S )Nc                      d} t          j        | f          }t          j        | dz
  f          }t          t	          |                    D ]$}t          j        |||dz                      ||<   %|S r  )r   r  r  r   r   rv  )r   na_maskr  r   s       rT   r  z1TestParforsMisc.test_issue6774.<locals>.test_impl  so    AgqdmmGXq1uh''FCKK(( 5 5F71QU7#344q		MrV   r  r  s     rT   test_issue6774zTestParforsMisc.test_issue6774  s+    	 	 	 	

9rV   c                 6    d }|                      |           d S )Nc                  F    t          j        t          t          f          } | S rX   )r   r9  _GLOBAL_INT_FOR_TESTING1_GLOBAL_INT_FOR_TESTING2)bufs    rT   r  z9TestParforsMisc.test_issue4963_globals.<locals>.test_impl  s    (46NOPPCJrV   r  r  s     rT   test_issue4963_globalsz&TestParforsMisc.test_issue4963_globals  s+    	 	 	 	

9rV   c                 H    ddfd}|                      |           d S )Nr}   r~   c                  4    t          j        f          } | S rX   r  )r  _FREEVAR_INT_FOR_TESTING1_FREEVAR_INT_FOR_TESTING2s    rT   r  z:TestParforsMisc.test_issue4963_freevars.<locals>.test_impl  s    (57PQRRCJrV   r  )rQ   r  r  r  s     @@rT   test_issue4963_freevarsz'TestParforsMisc.test_issue4963_freevars  sH    $&!$%!	 	 	 	 	 	 	

9rV   c                    ddl m}m}m} t          j        d             t	          j        dd          fd            }|                     | ||| ||          g                     ||          f           d S )Nr   )ListTypeTupler  c                     d S rX   rz   r6  s    rT   _sinkz>TestParforsMisc.test_issue_9182_recursion_error.<locals>._sink  rj  rV   FT)r  r   c                 6   t          t          |                    D ]z}| D ]u}|d         }|d         }|dk    r	|d         }n8t          |          dk    r|d         |d         }}nt          |          dk    r	 |dk    r |            |           v{d S )Nr   r   r   r  rx  )	clausesnodespiterclauseclause_typeclause_variablesclause_var_1clause_var_2r  s	           rT   _ground_node_rulezJTestParforsMisc.test_issue_9182_recursion_error.<locals>._ground_node_rule  s    
  E

++ , ,% , ,F"()K'-ay$"a'''7':-..!33,Q/,Q/ '3
 -..!33"a''l+++l+++!,, ,rV   )numba.typesr  r  r  r   r   compile)rQ   r  r  r  r  r  s        @rT   test_issue_9182_recursion_errorz/TestParforsMisc.test_issue_9182_recursion_error  s    5555555555		 	 
	 
%$	/	/	/	, 	, 	, 	, 
0	/	,. 	!!dHHTNN;<<==	
 	
 	
 	
 	
rV   c                     t          d          d             }|                      |            |                                           d S )NTr   c                      d} t          d          D ]+}t          d          D ]}t          d          D ]}| dz  } ,| S r  r  )r  r   r   rw  s       rT   r  z8TestParforsMisc.test_lookup_cycle_detection.<locals>.foo  sd     CAYY ! !q ! !A"1XX ! !q!! JrV   r  )rQ   r  s     rT   test_lookup_cycle_detectionz+TestParforsMisc.test_lookup_cycle_detection  sU     
t				 	 
		 	.....rV   N)ru   rL   rv   rR  r  r  r  r  r  r  r@  rI  rY  r`  rf  rl  r;   ru  rz  r~  r  r  r  r  r<   r  r  r  r  r  r  rz   rV   rT   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&
 
 
    %
 %
 %
N/ / / / /rV   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 rX   r   r   s         rT   r   zTestParforsDiagnostics.check  r  rV   c                     |                      |          }|                      |          }|                     ||           d S rX   )_fusion_equivalentr   )rQ   r  r  r   r   s        rT   assert_fusion_equivalencez0TestParforsDiagnostics.assert_fusion_equivalence  sD    ##C((##H--ArV   c                     t          t                    }t          |                                          t	          |                                          D ]}fd||         D             ||z
  <   |S )Nc                     g | ]}|z
  S rz   rz   )r   r   min_keys     rT   r   z=TestParforsDiagnostics._fusion_equivalent.<locals>.<listcomp>  s    >>>G>>>rV   )r   r   r  keyssorted)rQ   thingnewr   r  s       @rT   r  z)TestParforsDiagnostics._fusion_equivalent  st     $ejjll##

%% 	? 	?A>>>>U1X>>>CG
rV   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   r2   r   dump)rQ   r  parfors_countr  r  r  r  replr   replacedr   hoisted_allocss               rT   assert_diagnosticsz)TestParforsDiagnostics.assert_diagnostics  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      rT   r  z9TestParforsDiagnostics.test_array_expr.<locals>.test_impl.  s*    A

AAq5LrV   rz   parfor_diagnosticsr   r  r  r~   )r  r  r   r   r  r  rQ   r  r   r  s       rT   test_array_exprz&TestParforsDiagnostics.test_array_expr-  s}    	 	 	 	

9&&y"55o&:;1/01a&k 	  	; 	; 	; 	; 	;rV   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      rT   r  z5TestParforsDiagnostics.test_prange.<locals>.test_impl;  s=    AAAYY  2v!HrV   rz   r  r   r  r  r  s       rT   test_prangez"TestParforsDiagnostics.test_prange:  sf    	 	 	 	

9&&y"55o&:;1=====rV   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   rw  s          rT   r  z;TestParforsDiagnostics.test_user_varname.<locals>.test_implJ  s    A

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

9&&y"55o&:; 	RR{7QRRRRR	T 	T 	T 	T 	TrV   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   rw  s       rT   r  z<TestParforsDiagnostics.test_nested_prange.<locals>.test_impl^  se    A!Q  AAYY ) ) ) )A"fqjAadGG)HrV   rz   r  r   r   )r  r  r  r  s       rT   test_nested_prangez)TestParforsDiagnostics.test_nested_prange]  s{    	 	 	 	

9&&y"55o&:;145s8 	  	= 	= 	= 	= 	=rV   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      rT   r  zCTestParforsDiagnostics.test_function_replacement.<locals>.test_implm  s&    A

A	!AHrV   rz   r  r   r   r  )r~  r  )r  r  r  r  r  s       rT   test_function_replacementz0TestParforsDiagnostics.test_function_replacementl  s    	 	 	 	

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

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

AAaaaDHrV   rz   r  r   r  r  r  s       rT   test_setitemz#TestParforsDiagnostics.test_setitem  sf    	 	 	 	

9&&y"55o&:;1=====rV   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   rG   )r   r   r9  r   )r   r<  r  r   temprw  s         rT   r  zBTestParforsDiagnostics.test_allocation_hoisting.<locals>.test_impl  si    AACAYY    x~~q    ADGGtBxJrV   rz   r  r   )r  r  r  s       rT   test_allocation_hoistingz/TestParforsDiagnostics.test_allocation_hoisting  sf    		 		 		 	

9&&y"55o&:;CCCCCrV   )NNNNN)ru   rL   rv   r   r  r  r  r  r  r  r  r  r!  r  r  rz   rV   rT   r  r    s        M M M  
   =A@DBF$ $ $ $:; ; ;> > >T T T,= = =G G G> > >
> 
> 
>D D D D DrV   r  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v r	d|	dz  z   }	n(t          j        dv rnt#          t          j                  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   rz   r   s     rT   r   z7TestPrangeBase.generate_prange_func.<locals>.<listcomp>  s:     "A "A "A&' ()G||!! "A "A "ArV   LOAD_GLOBALr   r   ))r  r  )r  rx  ))r  r  )r  r   )co_codeco_names)__code__r   r  r   bytesr   r  disBytecodeopnamer@   r  r   offsetr   rA   	PYVERSIONNotImplementedError	bytearrayreplacepytypesFunctionTypeglobals)rQ   r   patch_instancepyfunc_codeprange_namesnew_code	range_idxrange_locationsinstr
prange_idxr   rC  prange_codepfuncs                 rT   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"444*/2

$555)%/::: !455H~&&#o*>*>>>>># + +%a( *XH "))(3? * A A $['))<<rV   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 rz   r   r   s     rT   r   z0TestPrangeBase.prange_tester.<locals>.<listcomp>'  r   rV   Tr  r  r   )r   r  r   r   r  r  r  r   rQ  r   r(  r   )rQ   r   r   r   r  r   r  r  r   r   r  r   
fastcpfuncs                rT   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)ru   rL   rv   r  r  rz   rV   rT   r  r    s8        4 4 4l\ \ \ \ \rV   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   r9  r   r  s      rT   r  z0TestPrangeBasic.test_prange01.<locals>.test_implB  s=    AA1XX  Qw!HrV   r   Tr   r   r  r  s     rT   test_prange01zTestPrangeBasic.test_prange01A  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rV   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      rT   r  z0TestPrangeBasic.test_prange02.<locals>.test_implL  sG    AQA1a[[ # #7!a%HrV   r   Tr$  r%  r  s     rT   test_prange02zTestPrangeBasic.test_prange02K  r'  rV   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S Nr   r   rz  r  r   s     rT   r  z0TestPrangeBasic.test_prange03.<locals>.test_implV  ,    A2YY  QHrV   r   Tr$  r%  r  s     rT   test_prange03zTestPrangeBasic.test_prange03U  A    	 	 	
 	9Z*. 	 	0 	0 	0 	0 	0rV   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r   r   rz  r.  s     rT   r  z3TestPrangeBasic.test_prange03mul.<locals>.test_impl_  s,    A2YY  QHrV   r   Tr$  r%  r  s     rT   test_prange03mulz TestPrangeBasic.test_prange03mul^  r1  rV   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r   r   rz  r.  s     rT   r  z3TestPrangeBasic.test_prange03sub.<locals>.test_implh  s,    A2YY  QHrV   r   Tr$  r%  r  s     rT   test_prange03subz TestPrangeBasic.test_prange03subg  r1  rV   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S r-  rz  r.  s     rT   r  z3TestPrangeBasic.test_prange03div.<locals>.test_implq  r/  rV   r   Tr$  r%  r  s     rT   test_prange03divz TestPrangeBasic.test_prange03divp  r1  rV   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   rx  r   s       rT   r  z0TestPrangeBasic.test_prange04.<locals>.test_implz  sR    AAA1XX  66AaDDAaDDHrV   r   Tr$  r%  r  s     rT   test_prange04zTestPrangeBasic.test_prange04y  sA    		 		 		 	9Z*. 	 	0 	0 	0 	0 	0rV   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   rx  r  r   s       rT   r  z0TestPrangeBasic.test_prange05.<locals>.test_impl  sU    A2:...AA1a!eQ''  QqT	HrV   r   Tr$  r%  r  s     rT   test_prange05zTestPrangeBasic.test_prange05  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rV   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          ddd          D ]}|||         z  }|S rB  rC  rD  s       rT   r  z0TestPrangeBasic.test_prange06.<locals>.test_impl  sO    A2:...AA1a^^  QqT	HrV   r   Tr$  r%  r  s     rT   test_prange06zTestPrangeBasic.test_prange06  rF  rV   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          | d          D ]}|||         z  }|S rB  rC  rD  s       rT   r  z0TestPrangeBasic.test_prange07.<locals>.test_impl  sM    A2:...AA1a[[  QqT	HrV   r   Tr$  r%  r  s     rT   test_prange07zTestPrangeBasic.test_prange07  rF  rV   c                 <    d }|                      |dd           d S )Nc                      d} t          j        |           }d}t          t          |                    D ],}t          t          |                    D ]}|||         z  }-|S r  r   r  r   r   r   rx  r  r   rw  s        rT   r  z0TestPrangeBasic.test_prange08.<locals>.test_impl  sh    AAC3q66]]    s1vv    A1Q4KCC JrV   r   Tr$  r%  r  s     rT   test_prange08zTestPrangeBasic.test_prange08  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rV   c                 <    d }|                      |dd           d S )Nc                      d} t          j        |           }d}t          d          D ]}t          d          D ]}|||         z  } |S r  r   r  r   rP  s        rT   r  z2TestPrangeBasic.test_prange08_1.<locals>.test_impl  s\    AAC1XX    q    A1Q4KCC JrV   r   Tr$  r%  r  s     rT   test_prange08_1zTestPrangeBasic.test_prange08_1  rR  rV   c                 @    d }|                      |dgdd           d S )Nc                  `    d} d}t          |           D ]}t          |           D ]}|dz  }|S Nr  r   r   rz  )r   r  r   rw  s       rT   r  z0TestPrangeBasic.test_prange09.<locals>.test_impl  sK    AC1XX  q  A1HCCJrV   r   r   Tr  r   r   r%  r  s     rT   test_prange09zTestPrangeBasic.test_prange09  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rV   c                 @    d }|                      |dgdd           d S )Nc                  n    d} d}t          |           D ] }d}t          |           D ]}|dz  }||z  }!|S rY  rz  )r   acc2rw  acc1r   s        rT   r  z0TestPrangeBasic.test_prange10.<locals>.test_impl  sV    AD1XX  q  AAIDDKrV   r   r   TrZ  r%  r  s     rT   test_prange10zTestPrangeBasic.test_prange10  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rV   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 rz   )r   r  )r   rw  s     rT   r   zDTestPrangeBasic.test_prange11.<locals>.test_impl.<locals>.<listcomp>  s     000!BF1II000rV   rz  r   s    rT   r  z0TestPrangeBasic.test_prange11.<locals>.test_impl  s!    A00uQxx0000rV   r   Tr$  r%  r  s     rT   test_prange11zTestPrangeBasic.test_prange11  sA    	1 	1 	1 	9Z*. 	 	0 	0 	0 	0 	0rV   c                 <    d }|                      |dd           d S )Nc                      d} d}t          j        |          }t          t          |                     D ]}| ||         z  } | S r  rO  )r  r   rm  r   s       rT   r  z0TestPrangeBasic.test_prange12.<locals>.test_impl  sJ    CA

ACFF7^^  qtJrV   r   Tr$  r%  r  s     rT   test_prange12zTestPrangeBasic.test_prange12  sA    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rV   c                 b    d }|                      |t          j        d          dd           d S )Nc                 8    d}t          |           D ]}|dz  }|S r  rz  r  s      rT   r  z0TestPrangeBasic.test_prange13.<locals>.test_impl  s,    C1XX  qJrV   r  r   Tr$  )r  r   r  r  s     rT   test_prange13zTestPrangeBasic.test_prange13  sK    	 	 	
 	9bhqkk**. 	 	0 	0 	0 	0 	0rV   c                 x    d }|                      |t          j                            d          dd           d S )Nc                 d    d}t          t          |                     D ]}|| |         dz  z  }|S )Nr  r   r   r   )rx  r  r   s      rT   r  z0TestPrangeBasic.test_prange14.<locals>.test_impl  s:    A3q66]]  QqT!VHrV   r  r   Tr$  )r  r   r  r  r  s     rT   test_prange14zTestPrangeBasic.test_prange14  sR    	 	 	 	9binnQ&7&7*4*. 	 	0 	0 	0 	0 	0rV   c                 >    d }|                      |ddd           d S )Nc                 l    d}t          |           D ]!}t          j        d          }||d         z  }"|S )Nr   r*  r.  )r   r   r  )r  r  r   r   s       rT   r  z0TestPrangeBasic.test_prange15.<locals>.test_impl  s=    C1XX  GFOOqwJrV   r  r   Tr$  r%  r  s     rT   test_prange15zTestPrangeBasic.test_prange15  sC    	 	 	 	9d:*. 	 	0 	0 	0 	0 	0rV   c                 >    d }|                      |ddd           d S )Nc                 <    d}t          |  |           D ]}|dz  }|S r  rz  r  r  r   s      rT   r  z0TestPrangeBasic.test_prange16.<locals>.test_impl  s0    CA2q\\  qJrV   r  r   Tr$  r%  r  s     rT   test_prange16zTestPrangeBasic.test_prange16  sC    	 	 	
 	9d8*. 	 	0 	0 	0 	0 	0rV   c                 >    d }|                      |ddd           d S )Nc                 p    d}t          j        |           }t          |  |           D ]}|||         z  }|S r  rU  r  r  rm  r   s       rT   r  z0TestPrangeBasic.test_prange17.<locals>.test_impl  sA    C

AA2q\\  qtJrV   r  r   Tr$  r%  r  s     rT   test_prange17zTestPrangeBasic.test_prange17  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rV   c                 >    d }|                      |ddd           d S )Nc                     d}t          j        |           }t          |  d          D ]+}|||         z  }t          d|           D ]}|||         z  },|S )Nr   r~   rU  )r  r  rm  r   rw  s        rT   r  z0TestPrangeBasic.test_prange18.<locals>.test_impl&  sj    C

AA2q\\    qtr1    A1Q4KCC JrV   r  r   Tr$  r%  r  s     rT   test_prange18zTestPrangeBasic.test_prange18%  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rV   c                 >    d }|                      |ddd           d S )Nc                     d}| dz   }t          j        | |f          }t          |  |           D ]#}t          | |          D ]}||||f         z  }$|S r  rU  )r  r  Mrm  r   rw  s         rT   r  z0TestPrangeBasic.test_prange19.<locals>.test_impl2  sp    CAAAAA2q\\ # #r1 # #A1QT7NCC#JrV   r  r   Tr$  r%  r  s     rT   test_prange19zTestPrangeBasic.test_prange191  r  rV   c                 >    d }|                      |ddd           d S )Nc                 n    d}t          j        |           }t          d|           D ]}|||         z  }|S )Nr   rG   rU  rx  s       rT   r  z0TestPrangeBasic.test_prange20.<locals>.test_impl>  s?    C

A2q\\  qtJrV   r  r   Tr$  r%  r  s     rT   test_prange20zTestPrangeBasic.test_prange20=  rz  rV   c                 >    d }|                      |ddd           d S )Nc                 :    d}t          dd          D ]}|dz  }|S )Nr   rc  rG   r  rz  rt  s      rT   r  z0TestPrangeBasic.test_prange21.<locals>.test_implH  s.    C2r]]  qJrV   r  r   Tr$  r%  r  s     rT   test_prange21zTestPrangeBasic.test_prange21G  sC    	 	 	
 	9a*. 	 	0 	0 	0 	0 	0rV   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   rG   r]  r=  r>  s       rT   r  z0TestPrangeBasic.test_prange22.<locals>.test_implQ  sh    AAA2q\\  66AaDDUUAaDDAaDDHrV   r   Tr   r   r  r%  r  s     rT   test_prange22zTestPrangeBasic.test_prange22P  sH    	 	 	 	9X*.d 	 	L 	L 	L 	L 	LrV   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 N    t          t          |                     D ]}|| |<   | S rX   rm  rx  r   s     rT   r  z0TestPrangeBasic.test_prange23.<locals>.test_implb  s-    3q66]]  !HrV       r   r   Tr  r   r9  r  rQ   r  rx  s      rT   test_prange23zTestPrangeBasic.test_prange23`  sb    	 	 	 HRLL19a
*.d 	 	L 	L 	L 	L 	LrV   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 R    t          t          |            d          D ]}|| |<   | S r  rm  r  s     rT   r  z0TestPrangeBasic.test_prange24.<locals>.test_impll  s3    CFF7A&&  !HrV   r  r   r   Tr  r  r  s      rT   test_prange24zTestPrangeBasic.test_prange24j  sb    	 	 	 HRLL19a*.d 	 	L 	L 	L 	L 	LrV   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 rz   )r   
zeros_like)r   rH   rx  s     rT   r   zDTestPrangeBasic.test_prange25.<locals>.test_impl.<locals>.<listcomp>w  s#    6662=##666rV   )r   r   )rx  r   r  r   s   `   rT   r  z0TestPrangeBasic.test_prange25.<locals>.test_implu  sV    AA6666U1XX666C1XX  QAJrV   r  r   r   T)r  r   r   r  r  r   )
r   r  r  r   r   r   r  r  r   r   )rQ   r  rx  r   r  r  s         rT   test_prange25zTestPrangeBasic.test_prange25t  s    	 	 	 GENN9a!*4T15 	 	7 	7 	7 &&y5<??2DEEo&:;$88::^,,a00000rV   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 d    | d d d         }t          t          |                    D ]}|||<   | S rs  rm  )rx  r  r   s      rT   r  z0TestPrangeBasic.test_prange26.<locals>.test_impl  s<    ##A#A3q66]]  !HrV   r  r   r   Tr  r  r  s      rT   test_prange26zTestPrangeBasic.test_prange26  sb    	 	 	
 HRLL19a
*.d 	 	L 	L 	L 	L 	LrV   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  rw  r   rG  s         rT   r  z0TestPrangeBasic.test_prange27.<locals>.test_impl  s_    1Q46]] + +q + +Aq1QqSz**AA+1rV   r=  )
r  r  r  r  r  r  r  r  r  r  r   r   r   TrZ  )r  r   r  asarrayr  s     rT   test_prange27zTestPrangeBasic.test_prange27  si    	 	 	 	99R==:&;&;&;<<+,#*4*. 	 	0 	0 	0 	0 	0rV   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   r9  r   r   )
r   rf  r  rC  i0r  Pt1Pt2r  vl2s
             rT   r  z0TestPrangeBasic.test_prange28.<locals>.test_impl  s    (3q66""CQA''  sAvYsAvYee#IdQqTkCJrV         rU  r  r   r   r   r  r  r~   r   Tr  )r   r  r  rO  s       rT   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rV   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  rz  )r  r  r   s      rT   r  z0TestPrangeBasic.test_prange29.<locals>.test_impl  s[    F  q    AaKFF  q    AaKFFMrV   TFr%  r  s     rT   test_prange29zTestPrangeBasic.test_prange29  sE    	 	 	 	9d+++9e,,,,,rV   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 rL  )r  r   r   r9  r  r   )
r   par
numthreadsn_parn_xr  chunklenr   r  r  s
             rT   r  z0TestPrangeBasic.test_prange30.<locals>.test_impl  s    IaLEa&&CXucl"*===FA+a/J>H:&& ? ?HA)()%*AAA(>qqq%*}%%MrV   r   r  rU  r9  r   )r   r  r  r  )rQ   r  r   r  s       rT   test_prange30zTestPrangeBasic.test_prange30  sc    	 	 	 HRYq!S))**h''9aa00000rV   N)(ru   rL   rv   rR  r&  r*  r0  r4  r7  r:  r?  rE  rI  rL  rQ  rV  r[  r`  rl  skiprd  rg  rj  rn  rq  ru  ry  r~  r  r  r  r  r  r  r  r  r  r  r  r  rz   rV   rT   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 1rV   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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   rz  r   r  r   s      rT   r  zRTestPrangeSpecific.test_prange_two_instances_same_reduction_var.<locals>.test_impl  =    A1XX  Qr66FAHrV   r  r%  r  s     rT   ,test_prange_two_instances_same_reduction_varz?TestPrangeSpecific.test_prange_two_instances_same_reduction_var  s/    	 	 	 	9a(((((rV   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 r  rz  r  s      rT   r  zKTestPrangeSpecific.test_prange_conflicting_reduction_ops.<locals>.test_impl  r  rV   r  zBReduction variable c has multiple conflicting reduction operators.)r  r   UnsupportedErrorr  r   r  r  rQ   r  r
  r   s       rT   %test_prange_conflicting_reduction_opsz8TestPrangeSpecific.test_prange_conflicting_reduction_ops  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   r*  r.  r  )rx  r  r   r   s       rT   r  zLTestPrangeSpecific.test_prange_two_conditional_reductions.<locals>.test_impl  sb    IA1XX  66FAA((Aw Qa4KrV   r%  r  s     rT   &test_prange_two_conditional_reductionsz9TestPrangeSpecific.test_prange_two_conditional_reductions   s-    		 		 		 	9%%%%%rV   c                 6    d }|                      |           d S )Nc                  h    d} t          d          D ]}t          d          D ]}|dk    r| dz  }  | S r  rz  )rx  r   r   s      rT   r  zCTestPrangeSpecific.test_prange_nested_reduction1.<locals>.test_impl  sP    A1XX  q  AAvvQ HrV   r%  r  s     rT   test_prange_nested_reduction1z0TestPrangeSpecific.test_prange_nested_reduction1  s-    	 	 	 	9%%%%%rV   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 )Nr  r   r#  r  s      rT   r  z<TestPrangeSpecific.test_check_error_model.<locals>.test_impl  s=    AA1XX  1u!HrV   rz   r   )	r  ZeroDivisionErrorr  r   r   r   r   r   r  )rQ   r  r
  r  pcrespfcresr  s          rT   test_check_error_modelz)TestPrangeSpecific.test_check_error_model  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  rm  )rx  r   r  s      rT   r  z?TestPrangeSpecific.test_check_alias_analysis.<locals>.test_impl3  s:    3q66]]  aD!!!HrV   r  r  rk  r   Tr  definenoaliasr   )r   r9  r  r  r  r   r   r   r   r-  rN  r7  r   rJ  )
rQ   r  rx  r  r   r   rO  r   r  r  s
             rT   test_check_alias_analysisz,TestPrangeSpecific.test_check_alias_analysis1  s*   	 	 	
 HRLL  A&&9a
*.d 	 	L 	L 	L)))T::U\!__%&&--eS99!!$''IIKK 	 	DAq  t##T		 $$TZZ	%:%:A>>>E	 	rV   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  rz  rt  s      rT   r  zJTestPrangeSpecific.test_prange_raises_invalid_step_size.<locals>.test_implJ  s0    C1a^^  qJrV   r  z4Only constant step size of 1 is supported for prange)r  r   rW  r  r   r  r  r  s       rT   $test_prange_raises_invalid_step_sizez7TestPrangeSpecific.test_prange_raises_invalid_step_sizeI  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
|          }d}	 |j                    D ]\  }
}|
|j                                        v rs|	                                }t          |          D ]O\  }}|                    |          r5|                     |                    ||dz                                 d}	 nP|                     |	d           d S )Nc                  B    d} d}t          |           D ]
}||dz  z  }|S )Nr  r   r$  rz  r  s      rT   r  zFTestPrangeSpecific.test_prange_fastmath_check_works.<locals>.test_implY  s5    AA1XX  QWHrV   r   Tr$  rz   z%[A-Z_0-9]?(.[0-9]+)+[.]?[i]?z)\s+%s = fmul fast double %s, 5.000000e-01z\s+z = fadd fast double z, Fr   z'fast instruction pattern was not found.)r  r  r   r-  r8  r  rN  r   r   r7  r  rL  rF  )rQ   r  r  r   r   _id
recipr_strreciprocal_inst	fadd_instfoundr  kernelr:  r   r   s                  rT    test_prange_fastmath_check_worksz3TestPrangeSpecific.test_prange_fastmath_check_worksU  s   	 	 	 	9Z*. 	 	0 	0 	0)))T::--eR88  &&-A
*Z3*%<==JJ"%##sssCC 1 2 2	
 $BHJJ 	 	LD&t|002222!,,..%h//  DAq&,,Q// 	Q(H(HIII $
 	HIIIIIrV   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }|d         }t          |           D ]
}|dz   ||<   |                                S r  r   r9  r   rv  )r   r   r   rw  s       rT   r  z8TestPrangeSpecific.test_parfor_alias1.<locals>.test_implz  sO    !Q  A!A1XX  1u!5577NrV   r  r%  r  s     rT   test_parfor_alias1z%TestPrangeSpecific.test_parfor_alias1y  s/    	 	 	 	9a(((((rV   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }t          |           D ]$}||         }t          |           D ]
}||z   ||<   %|                                S rX   r  )r   r   r   r   rw  s        rT   r  z8TestPrangeSpecific.test_parfor_alias2.<locals>.test_impl  si    !Q  A1XX  A$aQxx  !1u!5577NrV   r  r%  r  s     rT   test_parfor_alias2z%TestPrangeSpecific.test_parfor_alias2  s/    	 	 	 	9a(((((rV   c                 8    d }|                      |d           d S )Nc                     t          j        | | | f          }t          |           D ]A}||         }t          |           D ]'}||         }t          |           D ]}||z   |z   ||<   (B|                                S rX   r  )r   r   r   r   rw  r  r   s          rT   r  z8TestPrangeSpecific.test_parfor_alias3.<locals>.test_impl  s    !Q##A1XX # #A$aQxx # #!aDq # #AQ!A$$## 5577NrV   r  r%  r  s     rT   test_parfor_alias3z%TestPrangeSpecific.test_parfor_alias3  s/    	 	 	 	9a(((((rV   c                     d }|                      |dd          }|d         }d}|                     |t          |j                             d S )Nc                 .    t          |          D ]}| }|S rX   rz  )r   rf  rw  r   s       rT   r  z8TestPrangeSpecific.test_parfor_race_1.<locals>.test_impl  s#    1XX  HrV   r   r=  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  )rQ   r  r  warning_objexpected_msgs        rT   test_parfor_race_1z%TestPrangeSpecific.test_parfor_race_1  sc    	 	 	 ,,YB??%a(F 	lC(;$<$<=====rV   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   rU  r   )r   negativer   r9  )r  r0  r   this_matterss       rT   r  zGTestPrangeSpecific.test_nested_parfor_push_call_vars.<locals>.test_impl  s    AA1XX ( ( quuQQrx||__Q''1XX ( ( quuQQrx||__Q''HrV   Nr%  r  s     rT   !test_nested_parfor_push_call_varsz4TestPrangeSpecific.test_nested_parfor_push_call_vars  s-    
	 
	 
	 	9%%%%%rV   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   r9  r   r   rX  )zztclhlcr   ntr  s          rT   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+r6MrV   r   r   r   )r  N)r   r  r  r  )rQ   r  r<  r  r  s        rT   test_copy_global_for_parforz.TestPrangeSpecific.test_copy_global_for_parfor  sh    		 		 		 WaAYWQbg&&&9b"aSAAAAArV   c                 8    d }|                      |d           d S )Nc                 x    d}t           j        }t          d          D ]} |d          }| ||           z  }|S )Nr   r   rU  )r   r  r   )r   r  r0  r   r  s        rT   r  zGTestPrangeSpecific.test_multiple_call_getattr_object.<locals>.test_impl  sH    AA1XX   qvvQQqTT	HrV   rU  r%  r  s     rT   !test_multiple_call_getattr_objectz4TestPrangeSpecific.test_multiple_call_getattr_object  s/    	 	 	 	9c*****rV   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 r2  )r   r   r   )r   r   s     rT   r  zHTestPrangeSpecific.test_argument_alias_recarray_field.<locals>.test_impl  s/    3q66]]  AHrV   r   r   rf  r   Tr   )	r   r9  r0  r  viewrecarrayr   r   r   )rQ   r  X1X2X3rB  rC  v3
python_resnjit_respa_funcpa_ress               rT   "test_argument_alias_recarray_fieldz5TestPrangeSpecific.test_argument_alias_recarray_field  s<   	 	 	 Xb#uSz <===Xb#uSz <===Xb#uSz <===WWR[!!WWR[!!WWR[!! ))B--((
Y++,,y4000ggbkk""X...V,,,,,rV   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.
            rG   r   )r   )rm  r$  r   s      rT   
list_checkz>TestPrangeSpecific.test_mutable_list_param.<locals>.list_check  s.     B%C"	AHHQKKKJrV   c                 H    t          |           D ]}dg} |          }|S r  r  )r   r   rm  r   r  s       rT   r  z=TestPrangeSpecific.test_mutable_list_param.<locals>.test_impl   s3    AYY " "EJqMMHrV   r   Tr   Nr   r   )rQ   r  r  r  r  r  r  s         @rT   test_mutable_list_paramz*TestPrangeSpecific.test_mutable_list_param  s    
 
	 	 
		 	 	 	 	
 Yr]]
"4	??2&&y4000X...V,,,,,rV   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 rz   )r   )r   r   r   s     rT   r   zXTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_impl.<locals>.<listcomp>  s#    >>>1S1YY>>>rV   )r   r  r   r   r6  s   `rT   r  zDTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_impl  s4    8>>>>c!ff>>>???rV   )r   r   r  r   r   r   )r   r  r  r  r+  s      rT   test_list_comprehension_prangez1TestPrangeSpecific.test_list_comprehension_prange  s`    	@ 	@ 	@XgggS)))"(Aa5*D*D*DE9a(((((rV   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   r9  r  r   )imager   r   r  r   r  hs          rT   r  z>TestPrangeSpecific.test_ssa_false_reduction.<locals>.test_impl  st    HU[))E5;q>** % %!HQK%'66A66Aq!9aLrV   ra  r   r   )r   r9  r  r  )rQ   r  r  s      rT   test_ssa_false_reductionz+TestPrangeSpecific.test_ssa_false_reduction  sI    		 		 		 rx0009eQ22222rV   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   rm  s       rT   r  z@TestPrangeSpecific.test_list_setitem_hoisting.<locals>.test_impl*  sV    A"(+++A1XX  C!t!HrV   r%  r  s     rT   test_list_setitem_hoistingz-TestPrangeSpecific.test_list_setitem_hoisting'  s-    	 	 	 	9%%%%%rV   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  rz  )statesr   s     rT   r  z?TestPrangeSpecific.test_record_array_setitem.<locals>.test_impl9  s2    1XX % %#$q	%  % %rV   c                 F    | d         d         |d         d         k    sJ d S )Nr   r  rz   r   s     rT   r~  z>TestPrangeSpecific.test_record_array_setitem.<locals>.comparer=  s)    Q4;!A$u+------rV   r   )r  r!  r  )r   r!  r  r  r9  )rQ   state_dtyper  r~  s       rT   test_record_array_setitemz,TestPrangeSpecific.test_record_array_setitem5  s{    h 1233	% 	% 	%	/ 	/ 	/ 	98!;???/7j 	 	: 	: 	: 	: 	:rV   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 )Nr]  r   )r  r   )r$  r   r   s      rT   r  zKTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.test_implG  s:    A6;'' ' '!"QsAMrV   r   r   c                 F    t           j                            | |           d S rX   r|  r   s     rT   r~  zJTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.comparerO  r  rV   r  )r   r!  r  r9  r  )rQ   r&  r  r$  r~  s        rT   %test_record_array_setitem_yield_arrayz8TestPrangeSpecific.test_record_array_setitem_yield_arrayD  s    hbg/00	 	 	 "K000	* 	* 	* 	9!/7j 	 	: 	: 	: 	: 	:rV   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       rT   r  z4TestPrangeSpecific.test_issue7501.<locals>.test_implW  s    Xtg&&Fqyyt # #A1IIINIIII# t # #A1IIINIIII!9rV   r  r   r%  r  s     rT   test_issue7501z!TestPrangeSpecific.test_issue7501V  s1    	 	 	 	9a+++++rV   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 )NrT  )r  r$  rJ  r   r   )r   r  r  r   r  rV  rv  rX  )
rm  r   pointsr  r   expsr   pr  r<  s
             rT   r  z6TestPrangeSpecific.test_kde_example.<locals>.test_impld  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KrV   r  )r   r  r  r  )rQ   r  r   rm  s       rT   test_kde_examplez#TestPrangeSpecific.test_kde_examplec  sG    	 	 	 INN19a(((((rV   c                     t          j        t          j        ddgdt           j                  }|                     d|                                           d S )Nr  z#numba.tests.parfors_max_label_errorr  )rK   r  zTEST PASSED)r  r  r  r  r  r   decode)rQ   r  s     rT   test_issue_due_to_max_labelz.TestPrangeSpecific.test_issue_due_to_max_labelv  sT     ^T#HI;
 
 

 	mSZZ\\22222rV   c                 `    d }t          j        d          }|                     ||           d S )Nc                     t          j        |           }t          j        |           }t          t	          |                     D ]}|                                ||<   |S rX   )r   r  r  r   r   rv  )r   rx  r  r   s       rT   r  z4TestPrangeSpecific.test_issue7578.<locals>.test_impl  sQ    a  A&))C3q66]] ! !wwyy!HrV   rL  )r   r  r  r+  s      rT   test_issue7578z!TestPrangeSpecific.test_issue7578  s<    	 	 	 IcNN9a(((((rV   N) ru   rL   rv   rR  r  r  r  r  r;   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r'  r+  r/  r5  r7   r8  r;  rz   rV   rT   r  r    s       >>	) 	) 	)2 2 2& & && & & , , ],0  0
2 
2 
2"J "J "JH) ) )) ) )
) 
) 
)
> 
> 
>& & &*B B B.	+ 	+ 	+- - -,- - -6) ) )3 3 3(& & &: : :: : :$, , ,) ) )& 3 3 3 ) ) ) ) )rV   r  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   rZ   s    rT   setUpzTestParforChunksizing.setUp      q!!!!!rV   c                 $    t          d           d S r  r?  rZ   s    rT   tearDownzTestParforChunksizing.tearDown  rA  rV   c                    |                      t                      d           t          d           |                      t                      d           t          d           |                      t                      d           d S Nr   rk  )r   r   r   rZ   s    rT   $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5rV   c                     |                      t                      d           t          d          5  |                      t                      d           d d d            n# 1 swxY w Y   |                      t                      d           d S rE  )r   r   r   rZ   s    rT   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 rX   )r   rz   rV   rT   get_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.get_cs  s    )+++rV   c                      t          |           S rX   r?  r6  s    rT   set_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.set_cs  s    )!,,,rV   r   rk  r  )rQ   rK  rM  s      rT   "test_njit_parallel_chunksize_basicz8TestParforChunksizing.test_njit_parallel_chunksize_basic  s    		, 	, 
	, 
	- 	- 
	- 	1%%%q			1%%%q			1%%%%%rV   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 )Nrk  )r   r   )r   cs1cs2cs3s       rT   r  zATestParforChunksizing.test_njit_with_chunksize.<locals>.test_impl  s    (**C#A&& / /,../ / / / / / / / / / / / / / /(**CS= s   9= =rk  r   r  )rQ   r  rQ  rR  rS  s        rT   test_njit_with_chunksizez.TestParforChunksizing.test_njit_with_chunksize  sx    		! 	! 
	! "	!S#a   a   a     rV   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. Tr   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   r9  rM  r   r   r   r   )csr   r  inner_csr   s        rT   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  re  r   r  r   N)r   r   rF  r   all)rQ   r  rw  r   r  rX  s         rT   #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 	7rV   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 )NrG   r?  rz   rV   rT   neg_testzMTestParforChunksizing.test_njit_parallel_chunksize_negative.<locals>.neg_test  s    &r*****rV   /chunksize must be greater than or equal to zero)r  r   r   r   r  r  )rQ   rX  r]  r   s       rT   %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 )NrG   r^  )r  r   r   r   r  r  rQ   rX  r   s      rT   '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?  rz   rV   rT   r   zMTestParforChunksizing.test_njit_parallel_chunksize_invalid_type.<locals>.impl  s    &~66666rV   )The parallel chunksize must be an integer)r  r   TypingErrorr   r   r  r  )rQ   rX  r   r   s       rT   )test_njit_parallel_chunksize_invalid_typez?TestParforChunksizing.test_njit_parallel_chunksize_invalid_type  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 )Nrf  rg  )r  	TypeErrorr   r   r  r  ra  s      rT   +test_python_parallel_chunksize_invalid_typezATestParforChunksizing.test_python_parallel_chunksize_invalid_type  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1rc  N)ru   rL   rv   rR  rw   r@  rC  rF  rH  rN  rT  rZ  r_  rb  ri  rl  rz   rV   rT   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 2rV   r=  c                       e Zd ZdZd Zeej        d                         Ze ej        ddi          d                         Z	e ej        ddi          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 rz   r   r   s     rT   r   z8TestParforsVectorizer.get_gufunc_asm.<locals>.<listcomp>#  s     777Qa777rV   z%call\s+\w+\*\s+@do_scheduling_(\w+)\()r   rN  r   r4   r   r  r   r   r4  r8  r  findallr   r   r   r   r   assertNotEqual)rQ   r   schedule_typer   r   r   rp  rq  rr  env_opts	overridesr   r  r   pfunc_vectorizabler   asmschedtymatchess                      rT   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 -*%MNN!//$,*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   rW  )rx  r   r  r   s       rT   will_vectorizezJTestParforsVectorizer.test_vectorizer_fastmath_asm.<locals>.will_vectorizeA  s@    AAC1XX " "rwqzz!JrV   r   r   Tr   Fvaddpdvsqrtpd__svml_sqrtzmmvsqrtsdvaddsdN)r   r9  r  r  rF  )rQ   r  r  fast_asmslow_asmr  s         rT   test_vectorizer_fastmath_asmz2TestParforsVectorizer.test_vectorizer_fastmath_asm6  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++++	, 	,rV   NUMBA_BOUNDSCHECK0)envvarsc                 T   d }d }t          j        d          }|                     t          j                   |                     |d|d          }|                     |d|d          }|                                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  rx  r   r   s      rT   will_not_vectorizezTTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_not_vectorizeg  sB    AAA2q\\ % %wqt}}!HrV   c                     t          |           }t          |          D ]}t          j        | |                   | |<    | S rX   r  r  s      rT   r  zPTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_vectorizem  s>    AA1XX % %wqt}}!HrV   r   r   Tr  r   r  r  r  r  vmovupdN)r   r9  r  r   BOUNDSCHECKr  r  rF  )rQ   r  r  r  	novec_asmvec_asmr  s          rT   "test_unsigned_refusal_to_vectorizez8TestParforsVectorizer.test_unsigned_refusal_to_vectorize_  sh   	 	 		 	 	 hrll 	+,,,''(:Hc15 ( 7 7	 %%nj#15 & 7 7 !!## 	, 	,AOOIQ.///OOIN+++OOEN++++!! 	( 	(A OOIN@mq.@AAAOOIN+++OOEQJ''''	( 	(rV   c                    d }d }|                      t          j                   |                     |dd          }|                     |dd          }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   rz  r  s      rT   signed_variantzMTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.signed_variant  s5    AAA2q\\  QHrV   c                  <    d} d}t          |           D ]}||z  }|S )Nr  r  rz  r  s      rT   unsigned_variantzOTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.unsigned_variant  s1    AA1XX  QHrV   r   Tr  r   c                 D   g }|                                  D ]}|                                }|dk    rl|                    d          sW|                    d          sB|                    d          s-d|v s)|                    t	          j        dd|                     |S )N rF   rH   "r'  z[	])r7  strip
startswithr   r8  sub)r|  r  r   spds       rT   strip_instrszKTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.strip_instrs  s    C^^%% < <ggii "99cnnS&9&99(+s(;(; (+s(;(;  )@3(F(F

26&"c#:#:;;;JrV   r   )SequenceMatcherc                     | dk    S )N	rz   r6  s    rT   r  zGTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.<lambda>  s
    d rV   insertr[  rG   r  N)r  r   r  r  rN  difflibr  r   r   r   get_opcodes)rQ   r  r  
signed_asmunsigned_asmr  r   r  signed_instrunsigned_instrsmr   r   r  rH  rK  s                   rT   test_signed_vs_unsigned_vec_asmz5TestParforsVectorizer.test_signed_vs_unsigned_vec_asm  s   	 	 		 	 	 	+,,,((59 ) ; ;
**+;Z59 + ; ;	 	 	 $$&& 	 	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???@	@ 	@rV   N)ru   rL   rv   rw   r  r5   r1   run_test_in_subprocessr  r  r  rz   rV   rT   rn  rn  
  s        
 "# # #J $%, %, %$ Z%,N $X$.A3-GHHH)( )( IH Z)(V  %X$.A3-GHHH=@ =@ IH Z=@ =@ =@rV   rn  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   Tr   c                     d}t          |            t                    D ],}d|z  z   }t          |           t                      }||z  }-|S r  r   r   r   nthreadsr  r   
local_maskgntr  masks        rT   udtz6TestParforReductionSetNumThreads.test_add.<locals>.udt  a    CH%%%AYY  T\

+++%''s
JrV   r   r
  r   r  r  rQ   r  r  expectr  r  r  s        @@rT   test_addz)TestParforReductionSetNumThreads.test_add      $E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rV   c                     t          dt          j                  }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr  r   r   Tr   c                     d}t          |            t                    D ],}d|z  z   }t          |           t                      }||z  }-|S r  r  r  s        rT   r  z6TestParforReductionSetNumThreads.test_mul.<locals>.udt  r  rV   )r  r   r
  r   r  r  r  s        @@rT   test_mulz)TestParforReductionSetNumThreads.test_mul  s     6+,,E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rV   c                     t           j        }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr   r   Tr   c                     d}t          |            t                    D ]7}d|z  z   }t          |           t                      }t          ||          }8|S r  )r   r   r   r  r  s        rT   r  z6TestParforReductionSetNumThreads.test_max.<locals>.udt  se    CH%%%AYY $ $T\

+++%''#smmJrV   r  r  s        @@rT   r  z)TestParforReductionSetNumThreads.test_max  r  rV   N)ru   rL   rv   rR  r  r  r  rz   rV   rT   r  r    sK         - - -(- - -,- - - - -rV   r  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_DIAGNOSTICSTr   c                  x    d} t          j        | t           j                  }t          |           D ]}d||<   |S )Nr  r   r   )r   r9  r  r   )r   r   r   s      rT   r   z<TestDiagnosticEnvVar.test_diagnostics_env_var1.<locals>.impl  sB    Ha
333  AAaDDrV   zParallel Accelerator Optimizing)r  r  r2   r   r  r   )rQ   r  r   
the_outputs       rT   test_diagnostics_env_var1z.TestDiagnosticEnvVar.test_diagnostics_env_var1  s    14
/0 		&4     !  DFFF		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 __&&
7DDDDDs   $AAAN)ru   rL   rv   r1   r  r  rz   rV   rT   r  r    s>        $X$&&E E '&E E ErV   r  __main__rX   )ru  r  r8  r  r   rx   r  
subprocessr   r  r  	functoolsr   r  r   numpy.randomr   rn  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   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.compilerr,   r-   numba.core.compiler_machineryr.   r/   numba.core.typed_passesr0   numba.tests.supportr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   numba.core.extendingr?   numba.core.bytecoder@   rA   r  rl  rC   rm  ry   x86_onlyr  r  r   r   r   rh  rp  r  r  r   r  r  r  r  r  r  r  r  r=  r  r  r  r  rf  ro  r  r&  r  r  r  r  r  r   r  r=  rn  r  r  ru   mainrz   rV   rT   <module>r     st
    				 				 



   



                           / / / / / / / /  " " " " " " " "        = = = = = = = = = = = = = = = = = = = =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; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; C B B B B B B B B B B B B B 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	 	 	 Z Z Z Z Zh Z Z Zz       ? ? ?B	 	 	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 VO VO VO VO VOo VO VO VOr2 2 2 2 2X 2 2 2, q q q q q/ q q qh! # # # # # # # #4 f% f% f% f% f% f% f% f%R	 "; "; "; "; "; "; "; ";J :M :M :M :M :M :M :M :Mz q/ q/ q/ q/ q/o q/ q/ q/h lD lD lD lD lD_ lD lD lD^T T T T T_ T T Tn a1 a1 a1 a1 a1n a1 a1 a1H j) j) j) j) j) j) j) j)X w2 w2 w2 w2 w2H w2 w2 w2t 	A@ A@ A@ A@ A@N A@ A@ 
 A@H ?- ?- ?- ?- ?-x ?- ?- ?-D E E E E E8 E E E$ zHMOOOOO rV   