
    J/Phӈ                       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/ d d	l0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 d d
l7m8Z8 d dl9m:Z: d dl;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZB d dlCmDZE d dlFmGZGmHZH d dlImJZJmKZK d dlLmMZM d dlNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\ d dl]m^Z^ d dl_m`Z` d dl$maZa d dlbZbd dlcZceU G d deO                      Zd ecje         ejf                    dvd          ZgdZhdZi edd          Zjd Zke[ G d deO                      Zld  Zmd! Znd" Zod# Zpd$ Zqd% Zrd& Zsd' Ztd( Zud) Zvd* ZwdUd+Zxd, Zy G d- d.ez          Z{eU G d/ d0el                      Z|eU G d1 d2el                      Z}eU G d3 d4el                      Z~ G d5 d6eO          ZeU G d7 d8el                      ZeU G d9 d:eQel                      ZeU G d; d<el                      ZeU G d= d>el                      ZeU G d? d@el                      ZeU G dA dBel                      ZeU G dC dDel                      Z G dE dFel          ZeU G dG dHe                      Ze^dI             ZeU G dJ dKe                      ZeU G dL dMeO                      ZeUeg G dN dOe                                  ZeU G dP dQeO                      ZeU G dR dSeO                      ZedTk    r ecj                     dS dS )V    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)DictList)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      X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_parfors.pyrunnerzTestParforsRunner.runnerQ   sk    ''))//#..r288==bA##/>,0M 	$ 	; 	; 	; 	; 	;    c                 .    |                                   d S NrW   rS   s    rV   test_TestParforBasicz&TestParforsRunner.test_TestParforBasicY       rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforNumericalMiscz.TestParforsRunner.test_TestParforNumericalMisc\   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforNumPyz&TestParforsRunner.test_TestParforNumPy_   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsz"TestParforsRunner.test_TestParforsb   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsBitMaskz)TestParforsRunner.test_TestParforsBitMaske   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsDiagnosticsz-TestParforsRunner.test_TestParforsDiagnosticsh   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsLeaksz'TestParforsRunner.test_TestParforsLeaksk   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsMiscz&TestParforsRunner.test_TestParforsMiscn   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsOptionsz)TestParforsRunner.test_TestParforsOptionsq   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsSlicez'TestParforsRunner.test_TestParforsSlicet   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestParforsVectorizerz,TestParforsRunner.test_TestParforsVectorizerw   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestPrangeBasicz&TestParforsRunner.test_TestPrangeBasicz   r^   rX   c                 .    |                                   d S rZ   r[   r\   s    rV   test_TestPrangeSpecificz)TestParforsRunner.test_TestPrangeSpecific}   r^   rX   N)__name__rN   __qualname___numba_parallel_test_platformmachinerR   rW   r]   r`   rb   rd   rf   rh   rj   rl   rn   rp   rr   rt   rv    rX   rV   rE   rE   C   s        " (x'))Y66ttDH
; ; ;                            rX   rE   )i386x86_64zx86 only test      TestNamedTuplepart0part1c                     dS )z
    Used with check_arq_equality to indicate that we do not care
    whether the value of the parameter at the end of the function
    has a particular value.
    Nr|   abs     rV   null_comparerr      s	     	DrX   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 rZ   )r   	overloads)rS   funcsigflagss       rV   _compile_thiszTestParforsBase._compile_this   s,     "tC!!5!!$''1#66rX   c                 2    |                      ||d          S )NTparallelr   rS   r   r   s      rV   compile_parallelz TestParforsBase.compile_parallel   s    !!$d!;;;rX   c                 4    |                      ||dd          S )NT)r   fastmathr   r   s      rV   compile_parallel_fastmathz)TestParforsBase.compile_parallel_fastmath   s    !!$dT!JJJrX   c                 .    |                      ||          S rZ   r   r   s      rV   compile_njitzTestParforsBase.compile_njit   s    !!$,,,rX   c                     t          d |D                       }|                     ||          }|                     ||          }||fS )Nc                 6    g | ]}t          j        |          S r|   numbar   .0xs     rV   
<listcomp>z/TestParforsBase.compile_all.<locals>.<listcomp>        333U\!__333rX   )tupler   r   )rS   pyfuncargskwargsr   cpfunccfuncs          rV   compile_allzTestParforsBase.compile_all   sV    33d33344 &&vs33 !!&#..f}rX   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 ]}t          |t          j                  r)|                    |                    d                     Ft          |t          j                  r(|                    |                                           t          |t          j                  r|                    |           ||                    |           t          |t                     r)|                    t          j	        |                     t          |t                    r|                    |d d                     Bt          |t                    r)|                    t          j        |                     t          |t                    r)|                    t          j        |                     t          d          t          |          S )Nkz%Unsupported argument type encountered)r   
isinstancenpndarrayappendcopynumbernumbersNumberdeepcopylistr   r   
ValueError)r   new_argsr   s      rV   	copy_argsz:TestParforsBase.check_parfors_vs_others.<locals>.copy_args   s    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))))4(( NOODIaLL11114(( NOODIaLL1111$%LMMM??"rX   )
popentry_pointr   testingassert_almost_equalassertEqualtypelenzipr   )rS   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                          rV   check_parfors_vs_othersz'TestParforsBase.check_parfors_vs_others   s3   >  $4d;;$4d;;$4d;;!::&8$??"(**-A4"H"H	# 	# 	#4 )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 &%rX   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   rS   r   r   r   r   r   s         rV   checkzTestParforsBase.check  sO     )(7$777v$$VUFLTLLLVLLLLLrX   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   )rS   implarg_genr   r   s        rV   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)rS   r   r   r   r   argtyss         rV   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unsignedrJ   z$Unknown scheduler_type specified: %s)r   assertInlibraryget_llvm_str)rS   cresr   scheduler_strmsgs        rV   r   z TestParforsBase.check_scheduling*  sj    (%!777~!55< ~!5666mT\%>%>%@%@AAAAArX   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   rV   genz)TestParforsBase.gen_linspace.<locals>.gen9  s[      +aA&&&&&+aA&&&&&+aA&&&&&&&rX   c                 .    g | ]}t                    S r|   )next)r   isrcs     rV   r   z0TestParforsBase.gen_linspace.<locals>.<listcomp>?  s    ---aS		---rX   )r	   range)rS   r   ctr   r   s    `  @rV   gen_linspacezTestParforsBase.gen_linspace6  sP    	' 	' 	' 	' 	'
 CCEEll----599----rX   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     rV   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>H  s4     > > > ))F## > > >rX      )r   r   c                 6    g | ]}t          j        |          S r|   r   asfortranarrayr   s     rV   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>L  #    444r ##444rX   c                 8    g | ]}|                     d           S ))r   r     r  r   s     rV   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>O  s:     B B B ))I&& B B BrX      c                 6    g | ]}t          j        |          S r|   r	  r   s     rV   r   z9TestParforsBase.gen_linspace_variants.<locals>.<listcomp>S  r  rX   N)r   )rS   r   arr2dsarr3dss       rV   gen_linspace_variantsz%TestParforsBase.gen_linspace_variantsA  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4rX   Nc                 X    fd|D             }||D ]}|t          |          v sJ |S )z. helper function to filter out modules by namec                 &    g | ]}|j         v |S r|   name)r   r   magicstrs     rV   r   z/TestParforsBase._filter_mod.<locals>.<listcomp>W  s%    555a(af"4"4"4"4"4rX   )str)rS   modr  checkstrfiltr   s     `   rV   _filter_modzTestParforsBase._filter_modU  sP    55553555 * *3q66)))))rX   c                     d |j         j        j        j        j        D             }|                     |||          }|j                                         }g }|D ] }|j        |v r|                    |           !|S )z gets the gufunc LLVM Modulesc                     g | ]}|S r|   r|   r   s     rV   r   z7TestParforsBase._get_gufunc_modules.<locals>.<listcomp>_  s    JJJ!AJJJrX   )r  )	r   _codegen_engine_ee_modulesr  get_asm_strr  r   )	rS   r   r  r  r"  potential_matcheslib_asmretr  s	            rV   _get_gufunc_modulesz#TestParforsBase._get_gufunc_modules]  s    JJt|4<@IJJJ !,,Xx6> - @ @ ,**,,$ 	  	 Cx7""

3
rX   c                     d}|                      ||          }t                      }|D ]} ||          ||j        <   |S )z$ helper for gufunc IR/asm generation__numba_parfor_gufunc)r'  dictr  )rS   r   fnr  gufunc_modsr   r  s          rV   _get_gufunc_infoz TestParforsBase._get_gufunc_infol  sP     +..tX>>FF 	" 	"C"S''AchKKrX   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  )rS   r   s     rV   _get_gufunc_irzTestParforsBase._get_gufunc_irv  s     $$T3///rX   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 rZ   )r  emit_assembly)r  tms    rV   emit_asmz1TestParforsBase._get_gufunc_asm.<locals>.emit_asm  s    r'',,---rX   )r   r  _tmr-  )rS   r   r4  r3  s      @rV   _get_gufunc_asmzTestParforsBase._get_gufunc_asm  sA     \"&	. 	. 	. 	. 	.$$T8444rX   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        rV   _get_fast_instructionsz?TestParforsBase.assert_fastmath.<locals>._get_fast_instructions  sT    $r}HI ( (Ik1--=$$Q'''rX   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matchrS   s         rV   _assert_fastz5TestParforsBase.assert_fastmath.<locals>._assert_fast  sj    JC + + # #BLE}}
	****+ +rX   N)r   r/  items)
rS   r   r   r   _irr?  rO  r  guirrK  s
   `         rV   assert_fastmathzTestParforsBase.assert_fastmath  s     --fc::!!$''	 	 		+ 	+ 	+ 	+ 	+ ))++ 	 	JD$))$//DL	 	rX   rZ   )rw   rN   rx   __doc__ry   r   r   r   r   r   r   r   r   r   r   r   r  r  r'  r-  r/  r6  rS  r|   rX   rV   r   r      sN         "7 7 7
< < <K K K- - -	 	 	\5 \5 \5|M M M2 2 2G G G
B 
B 
B	. 	. 	.5 5 5(        0 0 05 5 5$ $ $ $ $rX   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c1rG  puts                   rV   blackscholes_implrj    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JrX   c                     t          |          D ]O}|t          j        ddt          j        |  t          j        ||          z            z   z  dz
  | z  |          z  }P|S NrW  )r   r   dotrZ  )YXw
iterationsr   s        rV   lr_implrr    sg    : N N	RVcS261"rva||*;#<#<<=CqH1MMMHrX   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   )mathrY  r   sum)r   jA	centroidsr   s     rV   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  s_     ; ; ;$% )BFAacF9QqqqS>,AA+E$F$FGG ; ; ;rX   r   )r   r   rz  r{  	numCenters    @rV   r   z'example_kmeans_test.<locals>.<listcomp>  sc     N N N?@; ; ; ; ; ;).y)9)9; ; ; N N NrX   c                 L    g | ] }|d d f                                          !S rZ   argmin)r   r   dists     rV   r   z'example_kmeans_test.<locals>.<listcomp>  s1    @@@!4!!!9++--@@@rX   c                 L    g | ]fd t                    D              S )c                     g | ];}t          j        k    |f                   t          j        k              z  <S r|   r   rx  )r   ry  rz  r   labelss     rV   r   z2example_kmeans_test.<locals>.<listcomp>.<listcomp>  sR     4 4 4%&  "va	1o66rvfai7H7HH 4 4 4rX   r|  )r   r   rz  Dr  s    @rV   r   z'example_kmeans_test.<locals>.<listcomp>  sa     O O O894 4 4 4 4 4*/((4 4 4 O O OrX   )shaper   r   array)
rz  r}  numIterinit_centroidsNlr  r{  r  r  s
   ``    @@@@rV   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		 rX   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-inferencer|   )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_passrJ   r  preparfor_passr   parfor_passs                 rV   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;rX   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  rP  	enumeratebodyr   r   r  r  Parfor)
r  r   r  r  r  	ret_countlabelblockr   rK  s
             rV   r   r     s    (D@@C@@KGRI,,..  u ,, 	 	GAt$ 4 ;<< Q		 rX   c                 b    t          | |fi |\  }}t          |j        |j        j                  S rZ   )r  _count_arrays_innerr  r  r  r  r   r  r  r  s        rV   countArraysr  %  s4    (D@@C@@KGRw~rx/?@@@rX   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  rP  r  r  r   r   r  r  r  r   
init_block)r  r   r  r  r  r  r  r  r  r   rK  s              rV   get_init_block_sizer  )  s    (D@@C@@KGR^FI 7 7u ,, 	7 	7GAt$ 4 ;<< 7S!5666		7 rX   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  )setrP  r  r  r   r   r  r  r  	loop_bodyr   r  r  r   Assigntargetr  r   ArrayCompatibleaddr   )	r  r  r  arr_setr  r  r   rK  parfor_blockss	            rV   r  r  6  s   IeeG 	. 	.u ,, 	. 	.GAt$ 4 ;<< I $ 3 3 5 5#'?a 0HHH	4++ ."74;+;#<$)$9; ;. DK,---	. WIrX   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          rV   countArrayAllocsr  H  s\    (D@@C@@KGRI&&(( ? ?.w>>>		rX   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   rG  )emptynumpy)r-   znumba.np.unsafe.ndarrayr   )r  r   r   r  r  r  r  r  r  r  r   r  valueExprrM  r'   r&   )r  r  r  rK  r   s        rV   r  r  Q  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rX   c                 d    t          | |fi |\  }}t          ||j        |j        j                  S rZ   )r  &_count_non_parfor_array_accesses_innerr  r  r  r  s        rV   countNonParforArrayAccessesr  b  s@    (D@@C@@KGR1'7>24(2BD D DrX   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  rP  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	            rV   r  r  g  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 rX   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 rZ   r  )r   vs     rV   	<genexpr>z _uses_indices.<locals>.<genexpr>  s$      55!qv555555rX   r   F)
r  r'   r)   r   r   r  rM  r  rP  r   )r  index	index_setind_defvarnamess        rV   r  r    s    zYtND%00G'27## .
m(C(C55w}555558i'((A--5rX   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 rZ   )r   	StateDictr  r  r  r   r  r  r  r  r  )rS   r  r  r   r  s        rV   __init__zTestPipeline.__init__  sg    '))
(
(

$
!
!%
#
 
rX   N)rw   rN   rx   r  r|   rX   rV   r  r    s#        	! 	! 	! 	! 	!rX   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)rS   r   r>  s      rV   r  zTestParforBasic.__init__  s]     -----Jry~~v..IbMM29R==!QSArX   c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                  *    t          j        d          S )Nr|   r   onesr|   rX   rV   	test_implz0TestParforBasic.test_simple01.<locals>.test_impl  s    72;;rX   '@do_scheduling' not foundassertRaisesAssertionErrorr   r   r  	exceptionrS   r  raisess      rV   test_simple01zTestParforBasic.test_simple01  s    	 	 	~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLL   A  AAc                 6    d }|                      |           d S )Nc                  *    t          j        d          S )Nr   r  r|   rX   rV   r  z0TestParforBasic.test_simple02.<locals>.test_impl  s    74== rX   r   rS   r  s     rV   test_simple02zTestParforBasic.test_simple02  s)    	! 	! 	!

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

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

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

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

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

9rX   c                 6    d }|                      |           d S )Nc                  T    t          j        d          t          j        d          z   S r4  r$  r|   rX   rV   r  z0TestParforBasic.test_simple12.<locals>.test_impl  s!    78$$r}R'8'888rX   r  r  s     rV   test_simple12zTestParforBasic.test_simple12  s)    	9 	9 	9

9rX   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 rl  )r   r%  r|   rX   rV   r  z0TestParforBasic.test_simple13.<locals>.test_impl  s    =$$$rX   r  r  r  s      rV   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 )Nr5  r      r  r|   rX   rV   r  z0TestParforBasic.test_simple14.<locals>.test_impl  s    78$$QUU++rX   r  r  s     rV   test_simple14zTestParforBasic.test_simple14  s)    	, 	, 	,

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

9rX   c                 2    d } | j         |g| j        R   dS )zAsame as corresponding test_simple_<n> case but using operator.addc                 ,    t          j        | |           S rZ   operatorr  rC  s       rV   r  z:TestParforBasic.test_simple_operator_15.<locals>.test_impl.      <B'''rX   NrI  r  s     rV   test_simple_operator_15z'TestParforBasic.test_simple_operator_15+  s6    	( 	( 	( 	
90t/000000rX   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||          S rZ   ro  rC  s       rV   r  z:TestParforBasic.test_simple_operator_16.<locals>.test_impl5  rq  rX   rI  r  s     rV   test_simple_operator_16z'TestParforBasic.test_simple_operator_163  6    	( 	( 	( 	
90t/000000rX   c                 2    d } | j         |g| j        R   d S )Nc                 ,    t          j        ||           S rZ   ro  rC  s       rV   r  z:TestParforBasic.test_simple_operator_17.<locals>.test_impl<  rq  rX   rI  r  s     rV   test_simple_operator_17z'TestParforBasic.test_simple_operator_17:  rv  rX   c                 l    d }d }t          j        d          }|                     |||g           d S )Nc                     | dz  } d| d d <   d S )Nr   r  r|   r   s    rV   r  z5TestParforBasic.test_inplace_alias.<locals>.test_implC  s    FAAaaaDDDrX   c                 F    t           j                            | |           d S rZ   r   r   assert_equalr   s     rV   comparerz4TestParforBasic.test_inplace_alias.<locals>.comparerG       J##Aq)))))rX   r   r   r   r  r   )rS   r  r  r   s       rV   test_inplace_aliasz"TestParforBasic.test_inplace_aliasA  sO    	 	 		* 	* 	* GAJJ

9aXJ
?????rX   N)"rw   rN   rx   rT  r  r  r  r  r  r&  r)  r-  r1  r6  r9  r<  r@  rJ  rN  rQ  r<   rV  r;   r[  r_  rb  re  ri  rl  r=   rr  ru  ry  r  r|   rX   rV   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
@ 
@ 
@ 
@ 
@rX   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ranfrx  )r   r   rh  s      rV   r  z2TestParforNumericalMisc.test_pi.<locals>.test_implS  sf    BINN1%%%)ABINN1%%%)ArvadQTkAo...22rX   i r   decimalr   )r   r   r   r   int64r  intpr  s     rV   test_pizTestParforNumericalMisc.test_piR  sy    	3 	3 	3
 	

9fa
000i%+AA1EEEY>>BBBBBrX   c                     t           j        d d          fdz  }|                     t          t          |          d           d S Nr   r   )r   float64r   r   rj  rS   r   s     rV   test_blackscholesz)TestParforNumericalMisc.test_blackscholes\  sA    aaa #a'&7>>BBBBBrX   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   rr  r  r  s     rV   test_logistic_regressionz0TestParforNumericalMisc.test_logistic_regressiona  s    aaa %-!!!"4emAAA6Fgt44a888)'488!<<<<<rX   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  )rS   r  r  centersrz  r  arg_typss          rV   test_kmeansz#TestParforNumericalMisc.test_kmeansh  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rX   N)	rw   rN   rx   rT  r  r  r;   r  r  r|   rX   rV   r  r  N  sm        55C C CC C C
 = = Z=K K K K KrX   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 rZ   rY  r   r  s     rV   r  z-TestParforNumPy.test_mvdot.<locals>.test_impl      6!Q<<rX   r   r   r?  r   r  )r   r   r  r   )rS   r  rz  r  s       rV   
test_mvdotzTestParforNumPy.test_mvdot}  se    	  	  	  K1b!!))!R00K1b!!

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

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

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

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

9a#####rX   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   irE  rF  s         rV   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%   rX   rK  r  rO  rP  s       rV   test_reshape_with_large_negz+TestParforNumPy.test_reshape_with_large_neg  rR  rX   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 rD  rE  )r   r   rmrH  rI  rJ  s         rV   r  zETestParforNumPy.test_reshape_with_too_many_neg_one.<locals>.test_impl  ss    Xq!Qirz:::!A#JEMM"b))#ai'111QQQq5		rX   rK  r  z7The reshape API may only include one negative argument.)	r  r   UnsupportedRewriteErrorr   r   r  r   r  r
  )rS   raisedr  r   r   r   s         rV   "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 rZ   )r   rx  prodr  r  r  r   s    rV   r  z0TestParforNumPy.test_0d_array.<locals>.test_impl  sD    6!99rwqzz)BF1II5q		ABF1IIMMrX      Fr   )r   r   r  r  s     rV   test_0d_arrayzTestParforNumPy.test_0d_array  s:    	N 	N 	N

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

9a   i%2B33Q32G1IJJANNNNNrX   N)rw   rN   rx   rT  r;   r  r  r  r  r  r  r  r  r  r  r
  r  r  r!  r*  r1  r=  rA  rQ  rU  r[  ra  rf  r|   rX   rV   r  r  y  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rX   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 rZ   rY  r  s     rV   ddotzHTestParforsUnsupported.test_unsupported_combination_raises.<locals>.ddot  s    va||#rX   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
  )rS   rZ  rk  rz  r  r   s         rV   #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)	rw   rN   rx   rT  unittestskipIfr:   r;   rm  r|   rX   rV   rh  rh    sP        ..X_Z!?@@2 2 Z A@2 2 2rX   rh  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 rZ   r|   )r   r   rh  s      rV   r  z,TestParfors.test_arraymap.<locals>.test_impl.  s    q519rX   c                  .                          d          S Nr  r  r\   s   rV   r  z+TestParfors.test_arraymap.<locals>.<lambda>1  s    t/I/I!/L/L rX   )r   r  s   ` rV   test_arraymapzTestParfors.test_arraymap-  s:    	 	 	 	I'L'L'L'LMMMMMrX   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S )Nr   r     )r   r  r  rx  ro  rn  s     rV   r  z0TestParfors.test_0d_broadcast.<locals>.test_impl4  s0    A!!A6!a%== rX   r|   r   r   r   r   r  s     rV   test_0d_broadcastzTestParfors.test_0d_broadcast3  K    	! 	! 	! 	

9i44a88888rX   c                 ~    d }|                      |           |                     t          |d          d           d S )Nc                      t          j        d          } t          j        d          }t          j        | |z             S Nry  )r   r  r;  rx  r{  s     rV   r  z-TestParfors.test_2d_parfor.<locals>.test_impl<  s2    !!A""A6!a%== rX   r|   r   r|  r  s     rV   test_2d_parforzTestParfors.test_2d_parfor;  r~  rX   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  r;  r{  s     rV   case1z)TestParfors.test_nd_parfor.<locals>.case1D  s5      !!A""Aa&LLLLLrX   c                  Z    t                                            d                    S rv  )r
   r  )r  rS   s   rV   r  z,TestParfors.test_nd_parfor.<locals>.<lambda>I  s%    5$*D*DQ*G*GHH rX   c                 0    t          j        | |z             S rZ   r  r{  s     rV   r  z-TestParfors.test_nd_parfor.<locals>.test_implK  s    6!a%== rX   )r   r   )rS   r  r  r  s   `  @rV   test_nd_parforzTestParfors.test_nd_parforC  sj    	 	 	
 IHHHH	! 	! 	! 	Ix000##Ix88888rX   c                 N    ddl m fd}d}|                     ||           d S )Nr   )r  c                 *     |           }|d         S r  r|   )r   rz  r  s     rV   r  z9TestParfors.test_np_func_direct_import.<locals>.test_implS  s    QAQ4KrX   o   )r  r  r   )rS   r  r   r  s      @rV   test_np_func_direct_importz&TestParfors.test_np_func_direct_importQ  sO    	 	 	 	 	 

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

A

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

9aa00000rX   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 rZ   r  r   s     rV   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>y  s    c!Qii rX   r   )rz  init_vals     rV   r  z*TestParfors.test_reduce.<locals>.test_implw  s    H//H===rX   r  r  r  c                  R    d } t          | t          j        g d          d          S )Nc                     | dz  S rv  r|   r8  s    rV   r  z<TestParfors.test_reduce.<locals>.test_impl.<locals>.<lambda>  s
    !q& rX   r   r   r  r  r   r   )r   r   r  )gs    rV   r  z*TestParfors.test_reduce.<locals>.test_impl  s*      A!RXooo66:::rX      c                 >    t          j        | | dk                       S ru  r  r  s    rV   r  z*TestParfors.test_reduce.<locals>.test_impl  s    6!AqD'??"rX   c                 Z    | d d df         }t          j        | |dk    df                   S )Nr   r  r   r  rz  r  s     rV   r  z*TestParfors.test_reduce.<locals>.test_impl  s/    !!!A#A6!AqDF)$$$rX   )   r  c                 ^    | d d df         }t          j        | |dk    ddf                   S )Nr   r  r   r   r  r  s     rV   r  z*TestParfors.test_reduce.<locals>.test_impl  s3    !!!A#A6!AqD1H+&&&rX   r   c                 4    t          j        |           }| |z
  S rZ   )r   amin)rz  min_vals     rV   r  z*TestParfors.test_reduce.<locals>.test_impl  s    gajjGw;rX   )r   r  r  r   r  r  r  assertTypingErrorr  r   r   r   r  rS   r  r   rz  s       rV   test_reducezTestParfors.test_reducev  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   cmathrY  accr   s     rV   r  z9TestParfors.test_use_of_reduction_var1.<locals>.test_impl  s0    CAYY & &jooJrX   CUse of reduction variable acc in an unsupported reduction function.r|   r  r   r   r   r  r
  rS   r  r   r  r  s        rV   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     rV   r  z9TestParfors.test_unsupported_floordiv1.<locals>.test_impl  s,    CAYY  	JrX   zParallel floordiv reductions are not supported. If all divisors are integers then a floordiv reduction can in some cases be parallelized as a multiply reduction followed by a floordiv of the resulting product.r|   )r  r   NumbaValueErrorr   r   r  r
  r  s        rV   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     rV   r  z4TestParfors.test_unsupported_xor1.<locals>.test_impl  s0    CAYY  q1uJrX   r  r|   r  r  s        rV   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 rZ   r  r  s     rV   r  z8TestParfors.test_parfor_array_access1.<locals>.test_impl  s    

A5577NrX   r  r   )r   r   r  r   r  rS   r  r   s      rV   test_parfor_array_access1z%TestParfors.test_parfor_array_access1  sV    	 	 	 

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

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

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

9a     rX   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   rx  )r   ro  rh  r   s       rV   r  z8TestParfors.test_parfor_array_access5.<locals>.test_impl0  sT    AAA\!__ " "QqsVZZ\\!HrX   r  r   r  r  s      rV   test_parfor_array_access5z%TestParfors.test_parfor_array_access5.  sX    	 	 	 

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

9c"""""rX   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 ru  )r   r  r   rm  )r  r  rp  ro  rn  r   r  s          rV   r  z8TestParfors.test_parfor_generate_fuse.<locals>.test_implI  s_    

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

A1XX ( (R"&A,,&HrX   r  r  r  )r   r   r  r   r  r   )rS   r  r   r  s       rV   test_parfor_generate_fusez%TestParfors.test_parfor_generate_fuseF  s    	 	 	 

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

9a#####rX   c                 j    d }|                      t          |t          j        f          d           d S )Nc                 Z    t          | f          }t          |           D ]
}|dz   ||<   |S )Nr&  )unsafe_emptyr   r   rz  r   s      rV   r  z;TestParfors.test_find_callname_intrinsic.<locals>.test_implc  s:    aT""A1XX  3w!HrX   r   )r   r  r   r  r  s     rV   test_find_callname_intrinsicz(TestParfors.test_find_callname_intrinsicb  s>    	 	 	 	))ej]CCQGGGGGrX   c                 8    d }|                      |d           d S )Nc                 f    d}t          |           D ]}|dz  }t          |           D ]}|dz  }|S r   r  r   r  r   s      rV   r  z7TestParfors.test_reduction_var_reuse.<locals>.test_implo  sL    CAYY  qAYY  qJrX   r  r  r  s     rV   test_reduction_var_reusez$TestParfors.test_reduction_var_reusem  s-    	 	 	 	

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

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

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

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

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

9c"""""rX   c                 8    d }|                      |d           d S )Nc                     d}t          j        |t           j                  }t          j        g d                              |          }t          j        |           D ]}||z  }|S )Nr  )rW  r&  r  r  rL  rM  )r   r;  r  r  r  r   r   r   r  r  r  r   s        rV   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NrX   r  r  r  s     rV   +test_two_d_array_reduction_with_float_sizesz7TestParfors.test_two_d_array_reduction_with_float_sizes  s-    	 	 	 	

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

9c"""""rX   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   r;  r  r   r   r  )r   r  r  r   s       rV   r  z;TestParfors.test_three_d_array_reduction.<locals>.test_impl  sP    ChsBG,,G\!__ 1 1273000NrX   r  r  r  s     rV   test_three_d_array_reductionz(TestParfors.test_three_d_array_reduction  s-    	 	 	 	

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

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

9binnS1122222rX   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   r;  r  ro  s    rV   r  z8TestParfors.test_array_compare_scalar.<locals>.test_impl  s!    27+++A6MrX   Nr  r  s     rV   test_array_compare_scalarz%TestParfors.test_array_compare_scalar  s+    	 	 	 	

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

9a
>>>>>rX   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        rV   r  z7TestParfors.test_prange_side_effects.<locals>.test_impl  s    8CFF"*555Dt99D\$''  A$Q\$'' ) )q'AaD.QKrX   r  r"  r   r  )	r   r  floatr   r   r   r   r  r  )rS   r  r   rh  s       rV   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rX   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       rV   r  z*TestParfors.test_tuple1.<locals>.test_impl0  sZ    DA\#a&&)) . .!Q$q')A--HrX   r  r  r-  s      rV   test_tuple1zTestParfors.test_tuple1/  :    	 	 	 IbMM

9a     rX   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   r6  s       rV   r  z*TestParfors.test_tuple2.<locals>.test_impl;  sR    7DA\#a&&)) $ $!Q!#HrX   r  r  r-  s      rV   test_tuple2zTestParfors.test_tuple2:  r9  rX   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   r6  s       rV   r  z*TestParfors.test_tuple3.<locals>.test_implF  sk    IbMM1%DA\#a&&)) 1 1!Q
T!W,q00HrX   r  r  r-  s      rV   test_tuple3zTestParfors.test_tuple3E  r9  rX   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       rV   r  z/TestParfors.test_namedtuple1.<locals>.test_implQ  sc    "!444EA\#a&&)) 6 6!ek1A55HrX   r  r  r-  s      rV   test_namedtuple1zTestParfors.test_namedtuple1P  r9  rX   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 rB  )r   r   r   r   r   )r   rC  r   r   rF  s       rV   r  z/TestParfors.test_namedtuple2.<locals>.test_impl]  sf    #O!1555EA\#a&&)) 6 6!ek1A55HrX   r  )r   r   r  r   )rS   r  r   rF  s      @rV   test_namedtuple2zTestParfors.test_namedtuple2[  sV    $%68JKK	 	 	 	 	 IbMM

9a     rX   c                     t          ddg          }d }d } |t          j        d                    }|                     |||g           d S )NTestNamedTuple3rh  c                     d| j         d d <   d S )Nr   rh  r|  s    rV   r  z/TestParfors.test_namedtuple3.<locals>.test_impll  s    ACFFFrX   c                 Z    t           j                            | j        |j                   d S rZ   )r   r   r   rh  r   s     rV   r  z.TestParfors.test_namedtuple3.<locals>.comparero  s$    J**1344444rX   r  rL  r  )r   r   r;  r   )rS   rJ  r  r  r   s        rV   test_namedtuple3zTestParfors.test_namedtuple3g  sp     %%7>>	 	 		5 	5 	5 Obhrll+++

9aXJ
?????rX   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 rZ   r|   r   s     rV   r  z1TestParfors.test_inplace_binop.<locals>.test_implv  s    FAHrX   r  r  r   r  )r   r  r   r   r   r   r  r  rS   r  ro  rn  s       rV   test_inplace_binopzTestParfors.test_inplace_binopu  s    	 	 	 IbMMBIbMMC

9a###i%*[3%G%G%*[3%G%G%IJ JKL	N 	N 	N 	N 	NrX   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   r;  uint64r  r   r   array_shapeindicesk_listr   r  s          rV   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MrX   r   rO  r-  s      rV   test_tuple_concatzTestParfors.test_tuple_concat  s@    	 	 	 HaV

9a     rX   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  rI   r"  r   rU  rW  s          rV   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MrX   r   rO  r-  s      rV   $test_tuple_concat_with_reverse_slicez0TestParfors.test_tuple_concat_with_reverse_slice  s@    		 		 		 HaV

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

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

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

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

9bhrllG44444rX   c                 `    d }d}|                      |t          j        |                     d S )Nc                 B    d}t          j        |          D ]}d| |<   | S )Nrp  r   rk  rm  s      rV   r  z6TestParfors.test_tuple_for_pndindex.<locals>.test_impl  s0    B^B''  !HrX   rp  rv  rq  s      rV   test_tuple_for_pndindexz#TestParfors.test_tuple_for_pndindex  s:    	 	 	
 

9bhrll+++++rX   c                 b    d }d}|                      |t          j        |          d           d S )Nc                 F    |df}t          j        |          D ]}d| |<   | S r  rk  )r   firstrn  r   s       rV   r  z5TestParfors.test_tuple_arg_literal.<locals>.test_impl  s4    B^B''  !HrX   rp  r  rv  rq  s      rV   test_tuple_arg_literalz"TestParfors.test_tuple_arg_literal  s<    	 	 	
 

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

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

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

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

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

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

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

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

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

9aD)))))rX   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      rV   r  z3TestParfors.test_prange_optional.<locals>.test_implu  s1    AYY ! !# CF! !rX   r  c                     | |k    S rZ   r|   r   rh  s     rV   r  z2TestParfors.test_prange_optional.<locals>.<lambda>}  s
    AF rX   r  rN  rZ   )r   r  r   r   r   r   rx  rS   r  r  s      rV   test_prange_optionalz TestParfors.test_prange_optionalt  s    	! 	! 	! 	!
 gbkk

9c4')z'E':':'< 	 	= 	= 	= 	D)))))rX   c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                      d} | d         S )Ng333333?g?r   r|   r|  s    rV   r  z8TestParfors.test_untraced_value_tuple.<locals>.test_impl  s    AQ4KrX   r  r  r  s      rV   test_untraced_value_tuplez%TestParfors.test_untraced_value_tuple  s    	 	 	 ~.. 	"&JJy!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"4c&:J6K6KLLLLLr  c                     d }|                      t                    5 }|                     |           d d d            n# 1 swxY w Y   |                     dt	          |j                             d S )Nc                  "    d} | d         d         S )N)r  r   r|   r|  s    rV   r  zBTestParfors.test_recursive_untraced_value_tuple.<locals>.test_impl  s    AQ47NrX   r  r  r  s      rV   #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arr3ry  totaln3r   s              rV   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<rX   r   r  r  r"  )r   r  r  r   r   r   r  r   )rS   r  r  r  s       rV   test_untraced_value_parforz&TestParfors.test_untraced_value_parfor  s{    	  	  	   {5;3//2i55q999i"(+++

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

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

9c4///

9c4...

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

9c2t,,,

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

9c2t,,,

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

9b!!!i%+AA1EEEEErX   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  rb  r   rh  r   r  r  p2r   ry  s               rV   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	# HrX   r   r  r  r  s     rV   test_issue9029zTestParfors.test_issue9029  s/    	 	 	, 	

9a#####rX   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  rw  ceilintr  )r   r   ro  rn  r  s        rV   r  z:TestParfors.test_fusion_no_side_effects.<locals>.test_impl	  sJ    A	!AAC1IIAq519rX   g@g333333@r   )r   r   r   r   r  r  s     rV   test_fusion_no_side_effectsz'TestParfors.test_fusion_no_side_effects	  sY    	 	 	 	

9c3'''i%-1OPPRSTTTTTrX   c                     t          d          d             }|                      |d          |                    d                     d S )NTr   c                 P    d}t          d           t          |           D ]}|}|S r  r   r   )r   r  r   s      rV   def_in_loopzCTestParfors.test_issue9256_lower_sroa_conflict.<locals>.def_in_loop%	  s6    AAAYY  HrX   r  r   r   py_func)rS   r  s     rV   "test_issue9256_lower_sroa_conflictz.TestParfors.test_issue9256_lower_sroa_conflict$	  s[    	t				 	 
		 	R+*=*=b*A*ABBBBBrX   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       rV   r  zLTestParfors.test_issue9256_lower_sroa_conflict_variant1.<locals>.def_in_loop0	  sI    AAQii   AAa!e8OrX   r  Fr   Tr   r   rS   r  r  s      rV   +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GrX   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        rV   r  zLTestParfors.test_issue9256_lower_sroa_conflict_variant2.<locals>.def_in_loop=	  s`    AAQii " " "#Ahh " "Ea!e8OrX   r  Fr   Tr  r  s      rV   +test_issue9256_lower_sroa_conflict_variant2z7TestParfors.test_issue9256_lower_sroa_conflict_variant2<	  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GrX   c                 
   t           j        ddg}i t          j        ddd}	 t	          j        ||t          j        d           d S # t          j        $ r+}d|j         }| 	                    |           Y d }~d S d }~ww xY w)	Nz-mz"numba.tests.parfor_iss9490_usecase1)PYTHONHASHSEEDNUMBA_NUM_THREADSzutf-8)envstderrencodingzsubprocess failed with output:
)r   )
sys
executableosenvironsubpcheck_outputSTDOUTCalledProcessErroroutputfail)rS   cmdenvsr  r   s        rV   "test_issue9490_non_det_ssa_problemz.TestParfors.test_issue9490_non_det_ssa_problemJ	  s     N0


j
 " "%
 
 
	ct%)['.0 0 0 0 0 0 & 	 	 	?QX??CII#I	s   "A B A==BN)Trw   rN   rx   rT  rv  r}  r  r  r  r  r  r  r  r  r  r  r  r  r;   r  r  r  r=   r  r  r  r  r  r  r  r  r
  r  r  r  r  r  r   r$  r(  r.  r3  r8  r<  r?  rD  rH  rN  rR  r[  r^  rd  rh  rr  rw  rz  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r<   r@   r  r|   rX   rV   rq  rq  )  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 "  #" \  rX   rq  c                        e Zd Zd Zd Zd ZdS )TestParforsLeaksc                 N     | j         |g|R  \  }} | j        |||g|R i | d S rZ   r   r   s         rV   r   zTestParforsLeaks.checkg	  M    ((7$777v$$VUFLTLLLVLLLLLrX   c                     d }t          j        d                              t           j                  }|                     ||           d S )Nc                 *    |                                  S rZ   ra  )r  s    rV   r  z2TestParforsLeaks.test_reduction.<locals>.test_implm	  s    7799rX   r  r   r  r  r  r   r  s      rV   test_reductionzTestParforsLeaks.test_reductionk	  sJ    	 	 	 imm""2:..

9c"""""rX   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  rW  r   )r   r  )r  r   r   r   s       rV   r  z@TestParforsLeaks.test_multiple_reduction_vars.<locals>.test_implu	  sT    AACH%% ' 'SVR3q6A:&&q5LrX   r  r"  r  s      rV   test_multiple_reduction_varsz-TestParforsLeaks.test_multiple_reduction_varss	  sJ    	 	 	 imm""2:..

9c"""""rX   N)rw   rN   rx   r   r#  r&  r|   rX   rV   r  r  e	  sD        M M M# # #
# 
# 
# 
# 
#rX   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      rV   r  z6TestParforsSlice.test_parfor_slice1.<locals>.test_impl	  s2    7DQ!AaC%1QqsU8#AHrX   r  r   r   r  r  s     rV   test_parfor_slice1z#TestParforsSlice.test_parfor_slice1	  s5    	 	 	
 	

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

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

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

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

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

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

9bimm33E::;;;;;rX   c                     d }|                      |t          j        d                              d                     d S )Nc                 h    | j         \  }}|                                 }| dddf         |dd df<   |S )Nr   r  r   rI   rX  r2  s       rV   r  z7TestParforsSlice.test_parfor_slice14.<locals>.test_impl 
  s<    GEQqA2a4yAaeHHrX   rz  r  rM  r  s     rV   test_parfor_slice14z$TestParforsSlice.test_parfor_slice14	  r_  rX   c                     d }|                      |t          j        d                              d                     d S )Nc                 p    | j         \  }}|                                 }| dddf         |d|dz
   d f<   |S )Nr   re  r  r   rX  r2  s       rV   r  z7TestParforsSlice.test_parfor_slice15.<locals>.test_impl	
  sB    GEQqAQr!tV9Aa!A#iLHrX   rz  r  rM  r  s     rV   test_parfor_slice15z$TestParforsSlice.test_parfor_slice15
  r_  rX   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      rV   r  z7TestParforsSlice.test_parfor_slice16.<locals>.test_impl
  s>    7ag%%%%AacFAa1gJq5LrX   r     Nr   )	r   r   r  r;  r   r  r  r   r   rS   r  r   s      rV   test_parfor_slice16z$TestParforsSlice.test_parfor_slice16
  s    	 	 	 	

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

9b"'"++.....rX   c                 6    d }|                      |           d S )Nc                  r    t          j        d          } t          j        dd          | dd<   | d         }|S )Nr  r   r_  r   rm  r  )r   r;  r  )r   rh  s     rV   r  z7TestParforsSlice.test_parfor_slice18.<locals>.test_impl,
  s4    AYq!__AacF!AHrX   r  r  s     rV   test_parfor_slice18z$TestParforsSlice.test_parfor_slice18*
  s+    	 	 	 	

9rX   c                 \    d }|                      |t          j        d                     d S )Nc                 *    | d dxx         dz  cc<   | S r  r|   r'  s    rV   r  z7TestParforsSlice.test_parfor_slice19.<locals>.test_impl6
  s     bqbEEEQJEEEHrX   r  r.  r  s     rV   test_parfor_slice19z$TestParforsSlice.test_parfor_slice194
  5    	 	 	 	

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

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

9b"%%%%%rX   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   r;  r   )r  r  r   r   s       rV   r  z7TestParforsSlice.test_parfor_slice22.<locals>.test_implQ
  s@    AAYY  R2YHrX   )r  r_  r  )r   r;  r  r   r  s       rV   test_parfor_slice22z$TestParforsSlice.test_parfor_slice22P
  sK    	 	 	 XfXa[[

9b"%%%%%rX   c                 \    d }|                      |t          j        d                     d S )Nc                     d| d d<   | S )Nr   r   r|   r8  s    rV   r  z7TestParforsSlice.test_parfor_slice23.<locals>.test_impl]
  s    AbqbEHrX   r  r.  r  s     rV   test_parfor_slice23z$TestParforsSlice.test_parfor_slice23[
  rz  rX   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }||d          }|d t          |                   }|S rZ   rr  r>  rz  r   r  r  s        rV   r  z7TestParforsSlice.test_parfor_slice24.<locals>.test_impld
  s4    A!""A'3q66'
AHrX   rg  r  r   r   r   r  rS   r  r   s      rV   test_parfor_slice24z$TestParforsSlice.test_parfor_slice24c
  W    	 	 	 sB 	6 	6AJJy"bgbkk15555	6 	6rX   c                     d }t          dd          D ],}|                     |dt          j        d          |           -d S )Nc                 p    t          j        |           }|d |         }|d t          |                   }|S rZ   rr  r  s        rV   r  z7TestParforsSlice.test_parfor_slice25.<locals>.test_impln
  s4    A"1"A'3q66'
AHrX   r  rg  r  r  r  s      rV   test_parfor_slice25z$TestParforsSlice.test_parfor_slice25m
  r  rX   c                 \    d }|                      |t          j        d                     d S )Nc                 f    | j         \  }|                                 }| dd         ||dz
   d <   |S )Nre  r  r   rX  r-  s      rV   r  z7TestParforsSlice.test_parfor_slice26.<locals>.test_implx
  s8    7DQA2a4A!fggJHrX   r  r   r   r  r  s     rV   test_parfor_slice26z$TestParforsSlice.test_parfor_slice26w
  s5    	 	 	 	

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

9bill+++++rX   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   rI   r]  c                     t          j        | dz                                | df          }d}t          j        |           D ]!}|||f                                         z  }"|S Nr  r   )r   r  r  r   r   rx  )r   ro  rh  r   tss       rV   r  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl
  se    Ia!e$$,,aV44a ( (A1b5'AArX   r  r  c                     d}t          j        | j        d                   D ]!}|| |f                                         z  }"|S r  )r   r   r  rx  )ro  rh  r   r  s      rV   r  zHTestParforsSlice.test_parfor_array_access_lower_slice.<locals>.test_impl
  sH    agaj11 ( (A1b5'AArX   )slicer   r   r  r  )rS   r  r   ro  r  s       @rV   $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!$$$$+	% 	%rX   N) rw   rN   rx   r/  r5  r9  r=  r@  rF  rI  r=   rN  rR  rU  rZ  r^  rb  rf  ri  ro  rs  rv  ry  r}  r  r  r  r  r  r  r  r  r|   rX   rV   r(  r(  	  s       + + += = =. . .. . .. . .. . .= = = ; ; ]; < < ]< ; ; ];> > >< < << < << < << < < ; ; ];/ / /  + + +6 6 6& & &	& 	& 	&+ + +6 6 66 6 6, , ,, , ,"% % % % %rX   r(  c                       e Zd Zd ZdS )TestParforsOptionsc                    d }|                      |t          j        d                     t          j        d d          f}|                     t          ||          d           |                     t          ||d          d           |                     t          ||dd          d           |                     t          ||ddd	          d
           |                     t          ||dddd          d           |                     t          ||ddddd          d           |                     t          ||dddddd          d           d S )Nc                 $   | j         d         }t          j        |          }t          j        d t	          |          D                       }| ||z  z   |d |<   t          |          D ]}||         | |         z  ||<   t          d |d          S )Nr   c                     g | ]}|S r|   r|   r   r   s     rV   r   zMTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<listcomp>
  s    0001000rX   c                     | |z   S rZ   r|   r  s     rV   r  zKTestParforsOptions.test_parfor_options.<locals>.test_impl.<locals>.<lambda>
  s
    QqS rX   )r  r   r  r  r   r   r   )r   r   r   r  r   s        rV   r  z9TestParforsOptions.test_parfor_options.<locals>.test_impl
  s    
A

A00eAhh00011AAIAbqbEAYY # #tad{!..!Q///rX   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   rn  s      rV   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	; 	; 	; 	; 	;rX   N)rw   rN   rx   r  r|   rX   rV   r  r  
  s#         ;  ;  ;  ;  ;rX   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  r|   r-  s      rV   r  z:TestParforsBitMask.test_parfor_bitmask1.<locals>.test_impl
  s    AAAaDHrX   r  r   r  r  s     rV   test_parfor_bitmask1z'TestParforsBitMask.test_parfor_bitmask1
  s7    	 	 	
 	

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

9a#####rX   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                     | |         | |<   | S rZ   r|   r   s     rV   r  z:TestParforsBitMask.test_parfor_bitmask3.<locals>.test_impl
  s    Q4AaDHrX   r  r   r  rP  s       rV   test_parfor_bitmask3z'TestParforsBitMask.test_parfor_bitmask3
  r  rX   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 "    d| z  |         | |<   | S rv  r|   r   s     rV   r  z:TestParforsBitMask.test_parfor_bitmask4.<locals>.test_impl
  s    E1:AaDHrX   r  r   r  rP  s       rV   test_parfor_bitmask4z'TestParforsBitMask.test_parfor_bitmask4
  r  rX   c                 n    d }t          j        d          }|dk    }|                     |||           d S )Nc                 .    | |         | |         z  | |<   | S rZ   r|   r   s     rV   r  z:TestParforsBitMask.test_parfor_bitmask5.<locals>.test_impl
  s    Q4!A$;AaDHrX   r  r   r  rP  s       rV   test_parfor_bitmask5z'TestParforsBitMask.test_parfor_bitmask5
  r  rX   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 rZ   r|   rE  s      rV   r  z:TestParforsBitMask.test_parfor_bitmask6.<locals>.test_impl   r  rX   r  r   r  )
r   r  r;  rx  r  r	  r   r   r  r
  )rS   r  r   r   r  r  s         rV   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)	rw   rN   rx   r  r  r  r  r  r  r|   rX   rV   r  r  
  ss        0 0 0$ $ $$ $ $$ $ $$ $ $M M M M MrX   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 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     rV   r   z9TestParforsMisc.test_no_warn_if_cache_set.<locals>.pyfunc  sD    '#,,CCH%%  A!JrX   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 r|   )r   has_dynamic_globals)r   r   s     rV   r   z=TestParforsMisc.test_no_warn_if_cache_set.<locals>.<listcomp>+  s3     E E E#'  $|? E E ErX   F)r   warningscatch_warningssimplefilterfilterwarningsr   r   NumbaWarningr   r   r   r  )rS   r   r   raised_warningsr  s        rV   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   rm  za[3]:r  )r   r;  r  printr|  s    rV   r   zITestParforsMisc.test_statement_reordering_respects_aliasing.<locals>.impl0  sS    AYq!__AacF'1Q4   '1Q4   HrX   r|   z	a[3]: 2.0)r   r4   r   getvaluer9  r   )rS   r   r   stdoutlines        rV   +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 rZ   )r   isinfr  s    rV   r  z;TestParforsMisc.test_parfor_ufunc_typing.<locals>.test_impl>  s    8A;;rX   r  Tr   )
r   r  r  r   r   r  r  sequential_parfor_loweringr   assert_array_equal)rS   r  rz  r   old_seq_flags        rV   test_parfor_ufunc_typingz(TestParforsMisc.test_parfor_ufunc_typing=  s    	 	 	 Hbfc]###d###I..}+F	K>BEM ;J))))A,,aAAA ?KEM ;;;lEM ;JJJJs   AB4 4Cc                 T    d }|                      t          |d          d           d S )Nc                      d} g d}t           j        j                                         |}t          j        d          D ]}| ||         z  } | |d         z   S )Nr   r  r   r   )r   r  r  init_pranger   )resr  dummyr   s       rV   r  z6TestParforsMisc.test_init_block_dce.<locals>.test_implN  s`    C++CM ,,...E\!__  s1vq>!rX   r|   r   )r   r  r  s     rV   test_init_block_dcez#TestParforsMisc.test_init_block_dceL  s:    	" 	" 	" 	,Y;;Q?????rX   c                 6    d }|                      |           d S )Nc                  b    d} t          d          D ]}| dz  } t          j        | f          }|S )Nr   r  r   r   r   r;  )r  rJ   r1  s      rV   r  zBTestParforsMisc.test_alias_analysis_for_parfor1.<locals>.test_implZ  s=    C1XX  q8SF##DKrX   r  r  s     rV   test_alias_analysis_for_parfor1z/TestParforsMisc.test_alias_analysis_for_parfor1Y  s+    	 	 	 	

9rX   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 rZ   )r1   r  r\   s    rV   r  z_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.__init__o  s    %d+++++rX   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                  rZ   )r   LoweringError)rS   otherr  s     rV   
differencezzTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_pass.<locals>.Broken.difference~  s    *0*>z*J*J$JrX   N)rw   rN   rx   r  r  s   rV   Brokenr   |  s5        !K !K !K !K !K !K !KrX   r  T)r  r  r  r  r   r   r  r  r  r   races)rS   r  blkr  r  r  s        rV   run_passz_TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParfors.run_passr  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   rX   N)rw   rN   rx   _namer  r	  r  s   rV   BreakParforsr  k  sB        #E, , ,             rX   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 rZ   )r/   define_nopython_pipeliner  add_pass_afterr2   finalize)rS   pmr  s     rV   define_pipelineszoTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.BreakParforsCompiler.define_pipelines  s?    '@LL!!,???trX   N)rw   rN   rx   r  )r  s   rV   BreakParforsCompilerr    s.              rX   r  )r   pipeline_classc                  8    d} t          d          D ]}| dz  } | S r  r  )r   rJ   s     rV   foozMTestParforsMisc.test_no_state_change_in_gufunc_lowering_on_error.<locals>.foo  s,    AAYY  QHrX   )r0   r1   r.   r   assertFalser   r  r  r  r  r   r  r   r  r
  )rS   r  r  r  r  r  s       @@rV   0test_no_state_change_in_gufunc_lowering_on_errorz@TestParforsMisc.test_no_state_change_in_gufunc_lowering_on_errord  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rw   rN   rx   r|   rX   rV   	DummyTyper            DrX   r  my_dummyc                       e Zd ZdS ).TestParforsMisc.test_issue_5098.<locals>.DummyNr  r|   rX   rV   Dummyr"    r  rX   r#  c                     S rZ   r|   )valr  
dummy_types     rV   typeof_Dummyz5TestParforsMisc.test_issue_5098.<locals>.typeof_Dummy  s	    rX   c                 N    t          |j                                                  S rZ   )r"   contextget_dummy_value)typobjr  s      rV   unbox_indexz4TestParforsMisc.test_issue_5098.<locals>.unbox_index  s    qy88::;;;rX   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 rZ   )r   r   r)  r  )r   fr  s      rV   bazzPTestParforsMisc.test_issue_5098.<locals>._get_method1.<locals>._foo.<locals>.baz  s/    A%'VAbhqkkN1Q44KrX   r"  r   r  )r,  r  r   r4  length
output_arrr   s          rV   _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!!rX   r|   )r,  r  r   r7  s       rV   _get_method1z5TestParforsMisc.test_issue_5098.<locals>._get_method1  s    " " " KrX   c                 *    |                                  S rZ   r  )r  s    rV   barz,TestParforsMisc.test_issue_5098.<locals>.bar  s    6688OrX   c                 `    |                      t          j        g dg dg                    S )NrW  r&  r  )r  rL  rM  )r.  r   r  )r  r:  s    rV   test1z.TestParforsMisc.test_issue_5098.<locals>.test1  s.    99RX&HII3OOOrX   )r   Opaquer   r#   OpaqueModelobjectr    registerr!   r   r   r   r  r  r  r  )
rS   r  r#  r'  r-  r8  r=  
save_stater:  r&  s
           @@rV   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_tuprI  r   s       rV   oversize_tuplezMTestParforsMisc.test_oversized_tuple_as_arg_to_kernel.<locals>.oversize_tuple  s6    GABZZ " "WS\!HrX   NUMBA_PARFOR_MAX_TUPLE_SIZE3r   zUse of a tuplezin a parallel region)r   r6   r  r   rl  r  r
  r   )rS   rH  r  errstrs       rV   %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dimsrh  r   s          rV   	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 NrX   )r  r  rW  g     @)lowr  r  )r   r  uniformr   )rS   rV  
tile_shapearray1array2s        rV   test_issue5167zTestParforsMisc.test_issue5167  sl    	 	 	 
""sz"JJ""sz"JJ

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

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

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



 rX   r   r   r  )rS   r:  r  s     @rV   test_issue3169zTestParforsMisc.test_issue3169  sh    		 	 
	 
t				 	 	 	 
		
 	aSFQJrX   c                     t          dd          }fd}t          d          d              |dd          }|                     ||           d S )	Nmytyper   c                 N    t          d          D ]} ||            | j        S ru  )r   r   )mydatar   inners     rV   outerz-TestParforsMisc.test_issue4846.<locals>.outer/  s4    AYY ! !a    8OrX   T)nogilc                 *    | |j         f}| |j        f}d S rZ   r   )r   rs  r3  r  s       rV   rt  z-TestParforsMisc.test_issue4846.<locals>.inner4  s    FHAFHAAArX   r   r   )r   r   r   )rS   rq  ru  rs  rt  s       @rV   test_issue4846zTestParforsMisc.test_issue4846*  s     Hj11	 	 	 	 	
 
D				 	 
		 #%%%

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

6rX   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   rh  s       rV   parallel_testz5TestParforsMisc.test_issue5277.<locals>.parallel_testJ  sU    DG__ , ,Q , ,A !C!CF1II,JrX   r5  r"  )r   r;  r  r   )rS   r  r  r  s       rV   test_issue5277zTestParforsMisc.test_issue5277H  sH    	 	 	 ht3'''

=$,,,,,rX   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   ry  s        rV   r  z5TestParforsMisc.test_issue5570_ssa_races.<locals>.fooV  sV    AYY " "q " "A !C1II" qJrX   )r   r   9   r@  )r   r   r;  r  r  )rS   r  r   r  r  s        rV   test_issue5570_ssa_racesz(TestParforsMisc.test_issue5570_ssa_racesU  s    	t				 	 
		 huoohvCVS!!KKVS))	
 	
 	
 	
 	
rX   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       rV   find_maxima_3D_jitzDTestParforsMisc.test_issue6095_numpy_max.<locals>.find_maxima_3D_jiti  sF    Gq" / /!%AAA+.6'??"rX   r   )r  r  r  )r   r   r  r  r  r  )rS   r  r   s      rV   test_issue6095_numpy_maxz(TestParforsMisc.test_issue6095_numpy_maxh  s    	t				# 	# 
		# 		qy--t$$&&t,,	
 	
 	
 	
 	
rX   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        rV   r  z3TestParforsMisc.test_issue5942_1.<locals>.test_implz  sm    B1Aq		 & &$&tQQQwKaaa a   A%    NrX   r  r   r"  )r   r;  r  r   )rS   r  r  r   r  r  s         rV   test_issue5942_1z TestParforsMisc.test_issue5942_1w  sm    	 	 	 (Aq628444(Aq628444

9b'*****rX   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   r;  r  r   r   )r  r   r  r  r  r   s         rV   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%    NrX   r  r   r  )rS   r  r  r   s       rV   test_issue5942_2z TestParforsMisc.test_issue5942_2  s9    
	 
	 
	 

9a#####rX   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   rI   )r   r  r   r  r  r  rT  norm)r  r   r  trr   dist_ts         rV   r3  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HrX   )r  r  r  )r  r  rW  )r   r   r  r  r  )rS   r3  r  s      rV   test_issue6102zTestParforsMisc.test_issue6102  su     
t			
	 
	 
	
	 HlllLLL122!aiill33333rX   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   rx  )r   na_maskr	  r   s       rV   r  z1TestParforsMisc.test_issue6774.<locals>.test_impl  so    AgqdmmGXq1uh''FCKK(( 5 5F71QU7#344q		MrX   r  r  s     rV   test_issue6774zTestParforsMisc.test_issue6774  s+    	 	 	 	

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

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

9rX   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 rZ   r|   r8  s    rV   _sinkz>TestParforsMisc.test_issue_9182_recursion_error.<locals>._sink  rm  rX   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  r{  )	clausesnodespiterclauseclause_typeclause_variablesclause_var_1clause_var_2r  s	           rV   _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+++!,, ,rX   )numba.typesr  r  r  r   r   compile)rS   r  r  r  r  r  s        @rV   test_issue_9182_recursion_errorz/TestParforsMisc.test_issue_9182_recursion_error  s    5555555555		 	 
	 
%$	/	/	/	, 	, 	, 	, 
0	/	,. 	!!dHHTNN;<<==	
 	
 	
 	
 	
rX   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   ry  s       rV   r  z8TestParforsMisc.test_lookup_cycle_detection.<locals>.foo  sd     CAYY ! !q ! !A"1XX ! !q!! JrX   r  )rS   r  s     rV   test_lookup_cycle_detectionz+TestParforsMisc.test_lookup_cycle_detection  sU     
t				 	 
		 	.....rX   c                     d }d} t          j        d          |          } t          j        d          |          }|                      ||           ||                     d S )Nc                     d}t          j        |           D ]G}t          j        |          }|di}t          d          D ]}||xx         dz  cc<   |||         z  }H|S )Nr   r  r   r   )r   r   r  r   )	num_nodesr  
inode_uintinodeprJ   s         rV   
issue_9678z=TestParforsMisc.test_issue_9678_build_map.<locals>.issue_9678  sx    C#l955    
J//CLq " "AeHHHMHHHHqxJrX   rz  Fr   T)r   jitr   )rS   r  r  issue_9678_serialissue_9678_parallels        rV   test_issue_9678_build_mapz)TestParforsMisc.test_issue_9678_build_map  s    	 	 	 	5EIu555jAA6ei666zBB**955,,Y77	9 	9 	9 	9 	9rX   N) rw   rN   rx   rT  r  r  r  r  r  r  rC  rL  r\  rc  ri  ro  r=   rx  r}  r  r  r  r  r  r>   r  r  r  r  r  r  r  r|   rX   rV   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/ / / 9 9 9 9 9rX   r  c                   d    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 ZdS )TestParforsDiagnosticsc                 N     | j         |g|R  \  }} | j        |||g|R i | d S rZ   r   r   s         rV   r   zTestParforsDiagnostics.check  r  rX   c                     |                      |          }|                      |          }|                     ||           d S rZ   )_fusion_equivalentr   )rS   r  r  r   r   s        rV   assert_fusion_equivalencez0TestParforsDiagnostics.assert_fusion_equivalence  sD    ##C((##H--ArX   c                     t          t                    }t          |                                          t	          |                                          D ]}fd||         D             ||z
  <   |S )Nc                     g | ]}|z
  S r|   r|   )r   r   min_keys     rV   r   z=TestParforsDiagnostics._fusion_equivalent.<locals>.<listcomp>+  s    >>>G>>>rX   )r   r   r  keyssorted)rS   thingnewr   r  s       @rV   r  z)TestParforsDiagnostics._fusion_equivalent   st     $ejjll##

%% 	? 	?A>>>>U1X>>>CG
rX   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   r4   r   dump)rS   r  parfors_countr  r  r  r  replr   replacedr   hoisted_allocss               rV   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      rV   r  z9TestParforsDiagnostics.test_array_expr.<locals>.test_implL  s*    A

AAq5LrX   r|   parfor_diagnosticsr   r  r  r   )r  r  r   r   r  r  rS   r  r   r  s       rV   test_array_exprz&TestParforsDiagnostics.test_array_exprK  s}    	 	 	 	

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

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

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

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

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

A	!AHrX   r|   r  r   r   r  )r  r  )r  r  r  r  r  s       rV   test_function_replacementz0TestParforsDiagnostics.test_function_replacement  s    	 	 	 	

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

9&&y"55o&:;1=====rX   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                  v    d} t          j        | dz             }d}t          |           D ]}|||         z
  }|S rl  r  r  s       rV   r  z>TestParforsDiagnostics.test_reduction_binop.<locals>.test_impl  sF    AAACAYY ! !AaDjJrX   r|   r  r   r  r  r  s       rV   test_reduction_binopz+TestParforsDiagnostics.test_reduction_binop  r  rX   c                     d }|                      |           |                     |d          }|j        d         }|                     |d           d S )Nc                  @    d} t          j        |           }d|d d <   |S )Nr  r_  r  )r   r   s     rV   r  z6TestParforsDiagnostics.test_setitem.<locals>.test_impl  s&    A

AAaaaDHrX   r|   r  r   r  r  r  s       rV   test_setitemz#TestParforsDiagnostics.test_setitem  sf    	 	 	 	

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

9&&y"55o&:;CCCCCrX   )NNNNN)rw   rN   rx   r   r  r  r  r  r  r  r  r  r#  r  r
  r  r|   rX   rV   r  r    s        M M M  
   =A@DBF$ $ $ $:; ; ;> > >T T T,= = =G G G> > >> > >
> 
> 
>D D D D DrX   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   r|   r   s     rV   r   z7TestPrangeBase.generate_prange_func.<locals>.<listcomp>  s:     "A "A "A&' ()G||!! "A "A "ArX   LOAD_GLOBALr   r   ))r  r  )r  rz  )r  r  ))r  r  )co_codeco_names)__code__r   r  r   bytesr  r  disBytecodeopnamerB   r  r   offsetr   rC   	PYVERSIONNotImplementedError	bytearrayreplacepytypesFunctionTypeglobals)rS   r   patch_instancepyfunc_codeprange_namesnew_code	range_idxrange_locationsinstr
prange_idxr   rF  prange_codepfuncs                 rV   generate_prange_funcz#TestPrangeBase.generate_prange_func  s   
 oK011! k22222  "A "A+6+?"A "A "A B BL[011HH $,227;;I Ok22 A A<=00+EI66)CC'..u|a/?@@@))) ..L\**Q.J"===*/2

J..)%/::: !455H~&&#o*>*>>>>># + +%a( *XH "))(3? * A A $['))<<rX   c                 f   |                     dd          }|                     dd          }|                     dd          }|                     ||          }t          d |D                       }|                     ||          }	t	          j        d          5 }
t	          j        d	           |                     ||          }ddd           n# 1 swxY w Y   |r|                     ||           |r%| 	                    ||          }t          d
|ifi |} | j        ||	|g|R i | |
S )a
  
        The `prange` tester
        This is a hack. It basically switches out range calls for prange.
        It does this by copying the live code object of a function
        containing 'range' then copying the .co_names and mutating it so
        that 'range' is replaced with 'prange'. It then creates a new code
        object containing the mutation and instantiates a function to contain
        it. At this point three results are created:
        1. The result of calling the original python function.
        2. The result of calling a njit compiled version of the original
            python function.
        3. The result of calling a njit(parallel=True) version of the mutated
           function containing `prange`.
        The three results are then compared and the `prange` based function's
        llvm_ir is inspected to ensure the scheduler code is present.

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

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


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

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

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

        r#  Nr   Fcheck_fastmath_resultc                 6    g | ]}t          j        |          S r|   r   r   s     rV   r   z0TestPrangeBase.prange_tester.<locals>.<listcomp>S  r   rX   Tr  r  r   )r   r-  r   r   r  r  r  r   rS  r   r*  r   )rS   r   r   r   r#  r   r/  r,  r   r   r  r   
fastcpfuncs                rV   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)rw   rN   rx   r-  r2  r|   rX   rV   r  r    s8        4 4 4l\ \ \ \ \rX   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   r;  r   r  s      rV   r  z0TestPrangeBasic.test_prange01.<locals>.test_impln  s=    AA1XX  Qw!HrX   r   Tr   r   r2  r  s     rV   test_prange01zTestPrangeBasic.test_prange01m  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rX   c                 <    d }|                      |dd           d S )Nc                  t    d} t          j        | dz
            }t          d|           D ]}d|z  ||dz
  <   |S )Nr  r   r&  r7  r  s      rV   r  z0TestPrangeBasic.test_prange02.<locals>.test_implx  sG    AQA1a[[ # #7!a%HrX   r   Tr8  r9  r  s     rV   test_prange02zTestPrangeBasic.test_prange02w  r;  rX   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S Nr  r   r|  r  r   s     rV   r  z0TestPrangeBasic.test_prange03.<locals>.test_impl  ,    A2YY  QHrX   r   Tr8  r9  r  s     rV   test_prange03zTestPrangeBasic.test_prange03  A    	 	 	
 	9Z*. 	 	0 	0 	0 	0 	0rX   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r  r   r|  rB  s     rV   r  z3TestPrangeBasic.test_prange03mul.<locals>.test_impl  s,    A2YY  QHrX   r   Tr8  r9  r  s     rV   test_prange03mulz TestPrangeBasic.test_prange03mul  rE  rX   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S )Nr  r  r   r|  rB  s     rV   r  z3TestPrangeBasic.test_prange03sub.<locals>.test_impl  s,    A2YY  QHrX   r   Tr8  r9  r  s     rV   test_prange03subz TestPrangeBasic.test_prange03sub  rE  rX   c                 <    d }|                      |dd           d S )Nc                  8    d} t          d          D ]}| dz  } | S rA  r|  rB  s     rV   r  z3TestPrangeBasic.test_prange03div.<locals>.test_impl  rC  rX   r   Tr8  r9  r  s     rV   test_prange03divz TestPrangeBasic.test_prange03div  rE  rX   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   rz  r   s       rV   r  z0TestPrangeBasic.test_prange04.<locals>.test_impl  sR    AAA1XX  66AaDDAaDDHrX   r   Tr8  r9  r  s     rV   test_prange04zTestPrangeBasic.test_prange04  sA    		 		 		 	9Z*. 	 	0 	0 	0 	0 	0rX   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   rz  r  r   s       rV   r  z0TestPrangeBasic.test_prange05.<locals>.test_impl  sU    A2:...AA1a!eQ''  QqT	HrX   r   Tr8  r9  r  s     rV   test_prange05zTestPrangeBasic.test_prange05  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rX   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          ddd          D ]}|||         z  }|S rV  rW  rX  s       rV   r  z0TestPrangeBasic.test_prange06.<locals>.test_impl  sO    A2:...AA1a^^  QqT	HrX   r   Tr8  r9  r  s     rV   test_prange06zTestPrangeBasic.test_prange06  rZ  rX   c                 <    d }|                      |dd           d S )Nc                      d} t          j        | t           j                  }d}t          | d          D ]}|||         z  }|S rV  rW  rX  s       rV   r  z0TestPrangeBasic.test_prange07.<locals>.test_impl  sM    A2:...AA1a[[  QqT	HrX   r   Tr8  r9  r  s     rV   test_prange07zTestPrangeBasic.test_prange07  rZ  rX   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   rz  r  r   ry  s        rV   r  z0TestPrangeBasic.test_prange08.<locals>.test_impl  sh    AAC3q66]]    s1vv    A1Q4KCC JrX   r   Tr8  r9  r  s     rV   test_prange08zTestPrangeBasic.test_prange08  A    	 	 	 	9Z*. 	 	0 	0 	0 	0 	0rX   c                 <    d }|                      |dd           d S )Nc                      d} t          j        |           }d}t          d          D ]}t          d          D ]}|||         z  } |S r  r   r  r   rd  s        rV   r  z2TestPrangeBasic.test_prange08_1.<locals>.test_impl  s\    AAC1XX    q    A1Q4KCC JrX   r   Tr8  r9  r  s     rV   test_prange08_1zTestPrangeBasic.test_prange08_1  rf  rX   c                 @    d }|                      |dgdd           d S )Nc                  `    d} d}t          |           D ]}t          |           D ]}|dz  }|S Nr  r   r   r|  )r   r  r   ry  s       rV   r  z0TestPrangeBasic.test_prange09.<locals>.test_impl  sK    AC1XX  q  A1HCCJrX   r   r   Tr#  r   r   r9  r  s     rV   test_prange09zTestPrangeBasic.test_prange09  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rX   c                 @    d }|                      |dgdd           d S )Nc                  n    d} d}t          |           D ] }d}t          |           D ]}|dz  }||z  }!|S rm  r|  )r   acc2ry  acc1r   s        rV   r  z0TestPrangeBasic.test_prange10.<locals>.test_impl  sV    AD1XX  q  AAIDDKrX   r   r   Trn  r9  r  s     rV   test_prange10zTestPrangeBasic.test_prange10  sF    	 	 	 	9aS*4*. 	 	0 	0 	0 	0 	0rX   z1list append is not thread-safe yet (#2391, #2408)c                 <    d }|                      |dd           d S )Nc                  8    d} d t          |           D             S )Nr  c                 6    g | ]}t          j        |          S r|   )r   r  )r   ry  s     rV   r   zDTestPrangeBasic.test_prange11.<locals>.test_impl.<locals>.<listcomp>  s     000!BF1II000rX   r|  r   s    rV   r  z0TestPrangeBasic.test_prange11.<locals>.test_impl
  s!    A00uQxx0000rX   r   Tr8  r9  r  s     rV   test_prange11zTestPrangeBasic.test_prange11  sA    	1 	1 	1 	9Z*. 	 	0 	0 	0 	0 	0rX   c                 <    d }|                      |dd           d S )Nc                      d} d}t          j        |          }t          t          |                     D ]}| ||         z  } | S r  rc  )r  r   ro  r   s       rV   r  z0TestPrangeBasic.test_prange12.<locals>.test_impl  sJ    CA

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

AA2q\\  qtJrX   r  r   Tr8  r9  r  s     rV   test_prange17zTestPrangeBasic.test_prange17G  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rX   c                 >    d }|                      |ddd           d S )Nc                     d}t          j        |           }t          |  d          D ]+}|||         z  }t          d|           D ]}|||         z  },|S )Nr   r   ri  )r  r  ro  r   ry  s        rV   r  z0TestPrangeBasic.test_prange18.<locals>.test_implR  sj    C

AA2q\\    qtr1    A1Q4KCC JrX   r  r   Tr8  r9  r  s     rV   test_prange18zTestPrangeBasic.test_prange18Q  C    	 	 	 	9a*. 	 	0 	0 	0 	0 	0rX   c                 >    d }|                      |ddd           d S )Nc                     d}| dz   }t          j        | |f          }t          |  |           D ]#}t          | |          D ]}||||f         z  }$|S r  ri  )r  r  Mro  r   ry  s         rV   r  z0TestPrangeBasic.test_prange19.<locals>.test_impl^  sp    CAAAAA2q\\ # #r1 # #A1QT7NCC#JrX   r  r   Tr8  r9  r  s     rV   test_prange19zTestPrangeBasic.test_prange19]  r  rX   c                 >    d }|                      |ddd           d S )Nc                 n    d}t          j        |           }t          d|           D ]}|||         z  }|S )Nr   rI   ri  r  s       rV   r  z0TestPrangeBasic.test_prange20.<locals>.test_implj  s?    C

A2q\\  qtJrX   r  r   Tr8  r9  r  s     rV   test_prange20zTestPrangeBasic.test_prange20i  r  rX   c                 >    d }|                      |ddd           d S )Nc                 :    d}t          dd          D ]}|dz  }|S )Nr   re  rI   r  r|  r  s      rV   r  z0TestPrangeBasic.test_prange21.<locals>.test_implt  s.    C2r]]  qJrX   r  r   Tr8  r9  r  s     rV   test_prange21zTestPrangeBasic.test_prange21s  sC    	 	 	
 	9a*. 	 	0 	0 	0 	0 	0rX   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   rI   r_  rQ  rR  s       rV   r  z0TestPrangeBasic.test_prange22.<locals>.test_impl}  sh    AAA2q\\  66AaDDUUAaDDAaDDHrX   r   Tr   r   r/  r9  r  s     rV   test_prange22zTestPrangeBasic.test_prange22|  sH    	 	 	 	9X*.d 	 	L 	L 	L 	L 	LrX   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 N    t          t          |                     D ]}|| |<   | S rZ   r  rz  r   s     rV   r  z0TestPrangeBasic.test_prange23.<locals>.test_impl  s-    3q66]]  !HrX       r   r   Tr  r   r;  r2  rS   r  rz  s      rV   test_prange23zTestPrangeBasic.test_prange23  sb    	 	 	 HRLL19a
*.d 	 	L 	L 	L 	L 	LrX   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 R    t          t          |            d          D ]}|| |<   | S r  r  r  s     rV   r  z0TestPrangeBasic.test_prange24.<locals>.test_impl  s3    CFF7A&&  !HrX   r  r   r   Tr  r  r  s      rV   test_prange24zTestPrangeBasic.test_prange24  sb    	 	 	 HRLL19a*.d 	 	L 	L 	L 	L 	LrX   c                 F   d }t          j        d          }|                     ||dgddd           |                     |t	          j        |          f          }|j        d         }|                                }|                     t          |          d           d S )	Nc                      t                     } fdt          |          D             }t          |          D ]
} |z   ||<   |S )Nc                 8    g | ]}t          j                  S r|   )r   
zeros_like)r   rJ   rz  s     rV   r   zDTestPrangeBasic.test_prange25.<locals>.test_impl.<locals>.<listcomp>  s#    6662=##666rX   )r   r   )rz  r   r  r   s   `   rV   r  z0TestPrangeBasic.test_prange25.<locals>.test_impl  sV    AA6666U1XX666C1XX  QAJrX   r  r   r   T)r#  r   r   r/  r  r   )
r   r  r2  r   r   r   r  r  r   r   )rS   r  rz  r   r  r  s         rV   test_prange25zTestPrangeBasic.test_prange25  s    	 	 	 GENN9a!*4T15 	 	7 	7 	7 &&y5<??2DEEo&:;$88::^,,a00000rX   c                 z    d }t          j        d          d d d         }|                     ||ddd           d S )Nc                 d    | d d d         }t          t          |                    D ]}|||<   | S ru  r  )rz  r  r   s      rV   r  z0TestPrangeBasic.test_prange26.<locals>.test_impl  s<    ##A#A3q66]]  !HrX   r  r   r   Tr  r  r  s      rV   test_prange26zTestPrangeBasic.test_prange26  sb    	 	 	
 HRLL19a
*.d 	 	L 	L 	L 	L 	LrX   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  ry  r   rI  s         rV   r  z0TestPrangeBasic.test_prange27.<locals>.test_impl  s_    1Q46]] + +q + +Aq1QqSz**AA+1rX   r?  )
r  r  r  r  r  r  r  r  r  r  r   r   r   Trn  )r2  r   r  asarrayr  s     rV   test_prange27zTestPrangeBasic.test_prange27  si    	 	 	 	99R==:&;&;&;<<+,#*4*. 	 	0 	0 	0 	0 	0rX   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   r;  r   r   )
r   rh  r  rF  i0r  Pt1Pt2r  vl2s
             rV   r  z0TestPrangeBasic.test_prange28.<locals>.test_impl  s    (3q66""CQA''  sAvYsAvYee#IdQqTkCJrX         rW  r  r   r   r   r  r  r   r   Tr  )r   r  r2  rQ  s       rV   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rX   c                 d    d }|                      |d           |                      |d           d S )Nc                 l    d}| rt          d          D ]}|dz  }nt          d          D ]}|dz  }|S )Nr   r   r  r|  )r  r	  r   s      rV   r  z0TestPrangeBasic.test_prange29.<locals>.test_impl  s[    F  q    AaKFF  q    AaKFFMrX   TFr9  r  s     rV   test_prange29zTestPrangeBasic.test_prange29  sE    	 	 	 	9d+++9e,,,,,rX   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 rO  )r  r   r   r;  r  r   )
r   par
numthreadsn_parn_xr	  chunklenr   r  r  s
             rV   r  z0TestPrangeBasic.test_prange30.<locals>.test_impl  s    IaLEa&&CXucl"*===FA+a/J>H:&& ? ?HA)()%*AAA(>qqq%*}%%MrX   r   r  rW  r<  r   )r   r  r  r2  )rS   r  r   r  s       rV   test_prange30zTestPrangeBasic.test_prange30  sc    	 	 	 HRYq!S))**h''9aa00000rX   N)(rw   rN   rx   rT  r:  r>  rD  rH  rK  rN  rS  rY  r]  r`  re  rj  ro  rt  rn  skiprx  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r|   rX   rV   r4  r4  i  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 1rX   r4  c                 
    | |fS rZ   r|   r   s     rV   test_call_hoisting_outcallr    s    q6MrX   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d Zd Zed             Z dS )TestPrangeSpecificz4 Tests specific features/problems found under prangec                 8    d }|                      |d           d S )Nc                 N    d}t          |           D ]}|dz  }|dk    r|dz  }|S Nr   r   r  r|  r   r  r   s      rV   r  zRTestPrangeSpecific.test_prange_two_instances_same_reduction_var.<locals>.test_impl  =    A1XX  Qr66FAHrX   r  r9  r  s     rV   ,test_prange_two_instances_same_reduction_varz?TestPrangeSpecific.test_prange_two_instances_same_reduction_var  s/    	 	 	 	9a(((((rX   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  r|  r  s      rV   r  zKTestPrangeSpecific.test_prange_conflicting_reduction_ops.<locals>.test_impl#  r  rX   r  zBReduction variable c has multiple conflicting reduction operators.)r  r   UnsupportedErrorr2  r   r  r
  rS   r  r  r   s       rV   %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,  r0  r  )rz  r  r   r   s       rV   r  zLTestPrangeSpecific.test_prange_two_conditional_reductions.<locals>.test_impl3  sb    IA1XX  66FAA((Aw Qa4KrX   r9  r  s     rV   &test_prange_two_conditional_reductionsz9TestPrangeSpecific.test_prange_two_conditional_reductions1  s-    		 		 		 	9%%%%%rX   c                 6    d }|                      |           d S )Nc                  h    d} t          d          D ]}t          d          D ]}|dk    r| dz  }  | S r  r|  )rz  r   r   s      rV   r  zCTestPrangeSpecific.test_prange_nested_reduction1.<locals>.test_impl@  sP    A1XX  q  AAvvQ HrX   r9  r  s     rV   test_prange_nested_reduction1z0TestPrangeSpecific.test_prange_nested_reduction1?  s-    	 	 	 	9%%%%%rX   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   r7  r  s      rV   r  z<TestPrangeSpecific.test_check_error_model.<locals>.test_implK  s=    AA1XX  1u!HrX   r|   r   )	r  ZeroDivisionErrorr-  r   r   r   r   r   r  )rS   r  r  r,  pcrespfcresr	  s          rV   test_check_error_modelz)TestPrangeSpecific.test_check_error_modelI  sv   	 	 	 011 	VIKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 )))T::%%eR00//r:: 011 	 V	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ##%%BF+++++s   599B==CCc                    d }t          j        d                              dd          }|                     ||ddd           |                     |d           }t          t          j        |          g          }|                     ||          }| 	                    |          }|
                                D ]O\  }}|                                D ]5}	d|	v r/||	v r+|                     |	                    d	          d
            n6Pd S )Nc                 b    t          t          |                     D ]}| |         }d|d d <   | S r  r  )rz  r   r  s      rV   r  z?TestPrangeSpecific.test_check_alias_analysis.<locals>.test_impld  s:    3q66]]  aD!!!HrX   r  r  rm  r   Tr  definenoaliasr   )r   r;  r  r2  r-  r   r   r   r   r/  rP  r9  r   rL  )
rS   r  rz  r,  r   r   rQ  r   r  r  s
             rV   test_check_alias_analysisz,TestPrangeSpecific.test_check_alias_analysisb  s*   	 	 	
 HRLL  A&&9a
*.d 	 	L 	L 	L)))T::U\!__%&&--eS99!!$''IIKK 	 	DAq  t##T		 $$TZZ	%:%:A>>>E	 	rX   c                     d }|                      t          j                  5 }|                     |d           d d d            n# 1 swxY w Y   d}|                     |t          |j                             d S )Nc                 <    d}t          d| d          D ]}|dz  }|S r  r|  r  s      rV   r  zJTestPrangeSpecific.test_prange_raises_invalid_step_size.<locals>.test_impl{  s0    C1a^^  qJrX   r  z4Only constant step size of 1 is supported for prange)r  r   rY  r2  r   r  r
  r  s       rV   $test_prange_raises_invalid_step_sizez7TestPrangeSpecific.test_prange_raises_invalid_step_sizez  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&  r|  r  s      rV   r  zFTestPrangeSpecific.test_prange_fastmath_check_works.<locals>.test_impl  s5    AA1XX  QWHrX   r   Tr8  r|   z%[A-Z_0-9]?(.[0-9]+)+[.]?[i]?z)\s+%s = fmul fast double %s, 5.000000e-01z\s+z = fadd fast double z, Fr   z'fast instruction pattern was not found.)r2  r-  r   r/  r:  r  rP  r   r   r9  r  rN  rH  )rS   r  r,  r   r   _id
recipr_strreciprocal_inst	fadd_instfoundr  kernelr<  r   r   s                  rV    test_prange_fastmath_check_worksz3TestPrangeSpecific.test_prange_fastmath_check_works  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IrX   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }|d         }t          |           D ]
}|dz   ||<   |                                S r  r   r;  r   rx  )r   r   r   ry  s       rV   r  z8TestPrangeSpecific.test_parfor_alias1.<locals>.test_impl  sO    !Q  A!A1XX  1u!5577NrX   r  r9  r  s     rV   test_parfor_alias1z%TestPrangeSpecific.test_parfor_alias1  s/    	 	 	 	9a(((((rX   c                 8    d }|                      |d           d S )Nc                     t          j        | | f          }t          |           D ]$}||         }t          |           D ]
}||z   ||<   %|                                S rZ   r  )r   r   r   r   ry  s        rV   r  z8TestPrangeSpecific.test_parfor_alias2.<locals>.test_impl  si    !Q  A1XX  A$aQxx  !1u!5577NrX   r  r9  r  s     rV   test_parfor_alias2z%TestPrangeSpecific.test_parfor_alias2  s/    	 	 	 	9a(((((rX   c                 8    d }|                      |d           d S )Nc                     t          j        | | | f          }t          |           D ]A}||         }t          |           D ]'}||         }t          |           D ]}||z   |z   ||<   (B|                                S rZ   r  )r   r   r   r   ry  r  r   s          rV   r  z8TestPrangeSpecific.test_parfor_alias3.<locals>.test_impl  s    !Q##A1XX # #A$aQxx # #!aDq # #AQ!A$$## 5577NrX   r  r9  r  s     rV   test_parfor_alias3z%TestPrangeSpecific.test_parfor_alias3  s/    	 	 	 	9a(((((rX   c                     d }|                      |dd          }|d         }d}|                     |t          |j                             d S )Nc                 .    t          |          D ]}| }|S rZ   r|  )r   rh  ry  r   s       rV   r  z8TestPrangeSpecific.test_parfor_race_1.<locals>.test_impl  s#    1XX  HrX   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.)r2  r   r  r  )rS   r  r  warning_objexpected_msgs        rV   test_parfor_race_1z%TestPrangeSpecific.test_parfor_race_1  sc    	 	 	 ,,YB??%a(F 	lC(;$<$<=====rX   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   rW  r   )r   negativer   r;  )r  r3  r   this_matterss       rV   r  zGTestPrangeSpecific.test_nested_parfor_push_call_vars.<locals>.test_impl  s    AA1XX ( ( quuQQrx||__Q''1XX ( ( quuQQrx||__Q''HrX   Nr9  r  s     rV   !test_nested_parfor_push_call_varsz4TestPrangeSpecific.test_nested_parfor_push_call_vars  s-    
	 
	 
	 	9%%%%%rX   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   r;  r   r   rZ  )zztclhlcr   ntr  s          rV   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+r6MrX   r   r"  r   r#  N)r   r  r  r2  )rS   r  r>  r  r  s        rV   test_copy_global_for_parforz.TestPrangeSpecific.test_copy_global_for_parfor  sh    		 		 		 WaAYWQbg&&&9b"aSAAAAArX   c                 8    d }|                      |d           d S )Nc                 x    d}t           j        }t          d          D ]} |d          }| ||           z  }|S )Nr   r   rW  )r   r  r   )r   r  r3  r   r  s        rV   r  zGTestPrangeSpecific.test_multiple_call_getattr_object.<locals>.test_impl  sH    AA1XX   qvvQQqTT	HrX   rW  r9  r  s     rV   !test_multiple_call_getattr_objectz4TestPrangeSpecific.test_multiple_call_getattr_object  s/    	 	 	 	9c*****rX   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 r4  )r   r   r   )r   r   s     rV   r  zHTestPrangeSpecific.test_argument_alias_recarray_field.<locals>.test_impl  s/    3q66]]  AHrX   r  r   rh  r"  Tr   )	r   r;  r2  r  viewrecarrayr   r   r   )rS   r  X1X2X3rD  rE  v3
python_resnjit_respa_funcpa_ress               rV   "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,,,,,rX   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.
            rI   r   )r   )ro  r&  r   s      rV   
list_checkz>TestPrangeSpecific.test_mutable_list_param.<locals>.list_check'  s.     B%C"	AHHQKKKJrX   c                 H    t          |           D ]}dg} |          }|S r  r  )r   r   ro  r   r)  s       rV   r  z=TestPrangeSpecific.test_mutable_list_param.<locals>.test_impl1  s3    AYY " "EJqMMHrX   r  Tr   Nr   r   )rS   r  r"  r#  r$  r%  r)  s         @rV   test_mutable_list_paramz*TestPrangeSpecific.test_mutable_list_param"  s    
 
	 	 
		 	 	 	 	
 Yr]]
"4	??2&&y4000X...V,,,,,rX   c                     d }t          j        g dt                    t          j        ddgt                    g}|                     ||           d S )Nc                 x     t          j         fdt          t                               D                       S )Nc                 :    g | ]}t          |                   S r|   )r   )r   r   r   s     rV   r   zXTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_impl.<locals>.<listcomp>@  s#    >>>1S1YY>>>rX   )r   r  r   r   r8  s   `rV   r  zDTestPrangeSpecific.test_list_comprehension_prange.<locals>.test_impl?  s4    8>>>>c!ff>>>???rX   )r   r   r  r"  r   r   )r   r  r  r2  r-  s      rV   test_list_comprehension_prangez1TestPrangeSpecific.test_list_comprehension_prange=  s`    	@ 	@ 	@XgggS)))"(Aa5*D*D*DE9a(((((rX   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   r;  r  r   )imager   r   r  r   r  hs          rV   r  z>TestPrangeSpecific.test_ssa_false_reduction.<locals>.test_implJ  st    HU[))E5;q>** % %!HQK%'66A66Aq!9aLrX   rc  r"  r   )r   r;  r  r2  )rS   r  r3  s      rV   test_ssa_false_reductionz+TestPrangeSpecific.test_ssa_false_reductionD  sI    		 		 		 rx0009eQ22222rX   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   ro  s       rV   r  z@TestPrangeSpecific.test_list_setitem_hoisting.<locals>.test_impl[  sV    A"(+++A1XX  C!t!HrX   r9  r  s     rV   test_list_setitem_hoistingz-TestPrangeSpecific.test_list_setitem_hoistingX  s-    	 	 	 	9%%%%%rX   c                     d }t           j        dz   }|                     |d t          |          D             dg           d S )Nc                    d t          t          |                     D             }t          t          |                     D ]0}| |         }t          j        d          }||d<   | |         |f||<   1|d         d         d         S )Nc                     g | ]@}t          j        t          j        t          j                   t          j        d          fAS key_type
value_typer   r   r  r   r  r  r   r;  r   rJ   s     rV   r   zMTestPrangeSpecific.test_tuple_hoisting.<locals>.test_impl.<locals>.<listcomp>i  >    }}}ef
EKEMRRRTVT\]^T_T_`}}}rX   r   r   )r   r   r   r;  inputsoutputsr   rh  r  s        rV   r  z9TestPrangeSpecific.test_tuple_hoisting.<locals>.test_implh  s    }}jopstzp{p{j|j|}}}G3v;;'' . .1IhqkkA$Qi-

1:a=##rX   r   c                 b    g | ],}t          j        t          j        t          j                   -S r=  r   r  r   r  r  r  s     rV   r   z:TestPrangeSpecific.test_tuple_hoisting.<locals>.<listcomp>r  .    &t&t&tfgtz5;SXS`'a'a'a&t&t&trX   r  r   r  r2  r   rS   r  r  s      rV   test_tuple_hoistingz&TestPrangeSpecific.test_tuple_hoistingf  u    	$ 	$ 	$ $q(9&t&tkpqrksks&t&t&t  GH  FI  	J  	J  	J  	J  	JrX   c                     d }t           j        dz   }|                     |d t          |          D             dg           d S )Nc                 (   d t          t          |                     D             }t          t          |                     D ]<}| |         }t          j        d          }||d<   t	          | |         |          ||<   =|d         d         d         S )Nc                     g | ]@}t          j        t          j        t          j                   t          j        d          fAS r<  r@  rA  s     rV   r   zLTestPrangeSpecific.test_call_hoisting.<locals>.test_impl.<locals>.<listcomp>w  rB  rX   r   r   )r   r   r   r;  r  rC  s        rV   r  z8TestPrangeSpecific.test_call_hoisting.<locals>.test_implv  s    }}jopstzp{p{j|j|}}}G3v;;'' H H1IhqkkA7q	3GG

1:a=##rX   r   c                 b    g | ],}t          j        t          j        t          j                   -S rG  rH  r  s     rV   r   z9TestPrangeSpecific.test_call_hoisting.<locals>.<listcomp>  rI  rX   r  rJ  rK  s      rV   test_call_hoistingz%TestPrangeSpecific.test_call_hoistingt  rM  rX   c                     t          j        dt           j        fg          }d }d }|                     |t          j        d|          |g           d S )Nr  c                 @    t          d          D ]}d| |         d<   d S )Nr   r  r|  )statesr   s     rV   r  z?TestPrangeSpecific.test_record_array_setitem.<locals>.test_impl  s2    1XX % %#$q	%  % %rX   c                 F    | d         d         |d         d         k    sJ d S )Nr   r  r|   r   s     rV   r  z>TestPrangeSpecific.test_record_array_setitem.<locals>.comparer  s)    Q4;!A$u+------rX   r   )r  r#  r  )r   r#  r  r2  r;  )rS   state_dtyper  r  s       rV   test_record_array_setitemz,TestPrangeSpecific.test_record_array_setitem  s{    h 1233	% 	% 	%	/ 	/ 	/ 	98!;???/7j 	 	: 	: 	: 	: 	:rX   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   )rU  r   r   s      rV   r  zKTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.test_impl  s:    A6;'' ' '!"QsAMrX   r  r"  c                 F    t           j                            | |           d S rZ   r~  r   s     rV   r  zJTestPrangeSpecific.test_record_array_setitem_yield_array.<locals>.comparer  r  rX   r  )r   r#  r  r;  r2  )rS   rW  r  rU  r  s        rV   %test_record_array_setitem_yield_arrayz8TestPrangeSpecific.test_record_array_setitem_yield_array  s    hbg/00	 	 	 "K000	* 	* 	* 	9!/7j 	 	: 	: 	: 	: 	:rX   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   r7  )r  caser	  r   s       rV   r  z4TestPrangeSpecific.test_issue7501.<locals>.test_impl  s    Xtg&&Fqyyt # #A1IIINIIII# t # #A1IIINIIII!9rX   r  r   r9  r  s     rV   test_issue7501z!TestPrangeSpecific.test_issue7501  s1    	 	 	 	9a+++++rX   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 )NrV  )r  r&  rL  r   r   )r   r  r  r   r  rX  rx  rZ  )
ro  r   pointsr  r   expsr   r  r  r>  s
             rV   r  z6TestPrangeSpecific.test_kde_example.<locals>.test_impl  s    AX...//FQA
AD1XX J JaD6zAo%!ad(3F1IIBF1q5MM)BF26"&Q--3H3H,I,IIIKrX   r  )r   r  r  r2  )rS   r  r   ro  s       rV   test_kde_examplez#TestPrangeSpecific.test_kde_example  sG    	 	 	 INN19a(((((rX   c                 `    d }t          j        d          }|                     ||           d S )Nc                     t          j        |           }t          j        |           }t          t	          |                     D ]}|                                ||<   |S rZ   )r   r  r  r   r   rx  )r   rz  r  r   s       rV   r  z4TestPrangeSpecific.test_issue7578.<locals>.test_impl  sQ    a  A&))C3q66]] ! !wwyy!HrX   rN  )r   r  r2  r-  s      rV   test_issue7578z!TestPrangeSpecific.test_issue7578  s<    	 	 	 IcNN9a(((((rX   N)!rw   rN   rx   rT  r  r  r  r  r=   r  r  r  r  r  r   r  r  r  r  r  r&  r,  r0  r5  r8  rL  rR  rX  r\  r`  re  r9   rh  r|   rX   rV   r  r    s       >>	) 	) 	)2 2 2& & && & & , , ],0  0
2 
2 
2"J "J "JH) ) )) ) )
) 
) 
)
> 
> 
>& & &*B B B.	+ 	+ 	+- - -,- - -6) ) )3 3 3(& & &J J JJ J J: : :: : :$, , ,) ) )& ) ) ) ) )rX   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   r\   s    rV   setUpzTestParforChunksizing.setUp      q!!!!!rX   c                 $    t          d           d S r  rl  r\   s    rV   tearDownzTestParforChunksizing.tearDown  rn  rX   c                    |                      t                      d           t          d           |                      t                      d           t          d           |                      t                      d           d S Nr   rm  )r   r   r   r\   s    rV   $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5rX   c                     |                      t                      d           t          d          5  |                      t                      d           d d d            n# 1 swxY w Y   |                      t                      d           d S rr  )r   r   r   r\   s    rV   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 rZ   )r   r|   rX   rV   get_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.get_cs  s    )+++rX   c                      t          |           S rZ   rl  r8  s    rV   set_cszHTestParforChunksizing.test_njit_parallel_chunksize_basic.<locals>.set_cs  s    )!,,,rX   r   rm  r+  )rS   rx  rz  s      rV   "test_njit_parallel_chunksize_basicz8TestParforChunksizing.test_njit_parallel_chunksize_basic  s    		, 	, 
	, 
	- 	- 
	- 	1%%%q			1%%%q			1%%%%%rX   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 )Nrm  )r   r   )r   cs1cs2cs3s       rV   r  zATestParforChunksizing.test_njit_with_chunksize.<locals>.test_impl  s    (**C#A&& / /,../ / / / / / / / / / / / / / /(**CS= s   9= =rm  r   r+  )rS   r  r~  r  r  s        rV   test_njit_with_chunksizez.TestParforChunksizing.test_njit_with_chunksize  sx    		! 	! 
	! "	!S#a   a   a     rX   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   r;  rP  r   r   r   r   )csr   r  inner_csr   s        rV   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  rg  r   r  r   N)r   r   rH  r   all)rS   r  ry  r   r  r  s         rV   #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 	7rX   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 )NrI   rl  r|   rX   rV   neg_testzMTestParforChunksizing.test_njit_parallel_chunksize_negative.<locals>.neg_test(  s    &r*****rX   /chunksize must be greater than or equal to zero)r  r   r   r   r  r
  )rS   rZ  r  r   s       rV   %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 )NrI   r  )r  r   r   r   r  r
  rS   rZ  r   s      rV   'test_python_parallel_chunksize_negativez=TestParforChunksizing.test_python_parallel_chunksize_negative1  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_typerl  r|   rX   rV   r   zMTestParforChunksizing.test_njit_parallel_chunksize_invalid_type.<locals>.impl;  s    &~66666rX   )The parallel chunksize must be an integer)r  r   TypingErrorr   r   r  r
  )rS   rZ  r   r   s       rV   )test_njit_parallel_chunksize_invalid_typez?TestParforChunksizing.test_njit_parallel_chunksize_invalid_type9  s    v122 	f7 7 T7 DFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 :c3v/0011111s   AAAc                     |                      t                    5 }t          d           d d d            n# 1 swxY w Y   d}|                     |t	          |j                             d S )Nr  r  )r  	TypeErrorr   r   r  r
  r  s      rV   +test_python_parallel_chunksize_invalid_typezATestParforChunksizing.test_python_parallel_chunksize_invalid_typeD  s    y)) 	3V">222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 :c3v/0011111r  N)rw   rN   rx   rT  ry   rm  rp  rs  ru  r{  r  r  r  r  r  r  r|   rX   rV   rj  rj    s          "" " "" " "6 6 66 6 6& & & ! ! ! 7 7 70
2 
2 
22 2 2	2 	2 	22 2 2 2 2rX   rj  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 r|   r   r   s     rV   r   z8TestParforsVectorizer.get_gufunc_asm.<locals>.<listcomp>e  s     777Qa777rX   z%call\s+\w+\*\s+@do_scheduling_(\w+)\()r   rP  r   r6   r   r-  r   r   r6  r:  r  findallr   r   r   r   r   assertNotEqual)rS   r   schedule_typer   r   r   r  r  r  env_opts	overridesr   r  r   pfunc_vectorizabler   asmschedtymatchess                      rV   get_gufunc_asmz$TestParforsVectorizer.get_gufunc_asmS  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   rY  )rz  r   r  r   s       rV   will_vectorizezJTestParforsVectorizer.test_vectorizer_fastmath_asm.<locals>.will_vectorize  s@    AAC1XX " "rwqzz!JrX   r  r   Tr   Fvaddpdvsqrtpd__svml_sqrtzmmvsqrtsdvaddsdN)r   r;  r  r  rH  )rS   r  r  fast_asmslow_asmr  s         rV   test_vectorizer_fastmath_asmz2TestParforsVectorizer.test_vectorizer_fastmath_asmx  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++++	, 	,rX   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  rz  r   r   s      rV   will_not_vectorizezTTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_not_vectorize  sB    AAA2q\\ % %wqt}}!HrX   c                     t          |           }t          |          D ]}t          j        | |                   | |<    | S rZ   r  r  s      rV   r  zPTestParforsVectorizer.test_unsigned_refusal_to_vectorize.<locals>.will_vectorize  s>    AA1XX % %wqt}}!HrX   r  r   Tr  r   r  r  r  r  vmovupdN)r   r;  r  r   BOUNDSCHECKr  r  rH  )rS   r  r  r  	novec_asmvec_asmr  s          rV   "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''''	( 	(rX   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   r|  r  s      rV   signed_variantzMTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.signed_variant  s5    AAA2q\\  QHrX   c                  <    d} d}t          |           D ]}||z  }|S )Nr  r  r|  r  s      rV   unsigned_variantzOTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.unsigned_variant  s1    AA1XX  QHrX   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 rH   rJ   "r)  z[	])r9  strip
startswithr   r:  sub)r  r  r   spds       rV   strip_instrszKTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.strip_instrs  s    C^^%% < <ggii "99cnnS&9&99(+s(;(; (+s(;(;  )@3(F(F

26&"c#:#:;;;JrX   r   )SequenceMatcherc                     | dk    S )N	r|   r8  s    rV   r  zGTestParforsVectorizer.test_signed_vs_unsigned_vec_asm.<locals>.<lambda>  s
    d rX   insertr]  rI   r  N)r  r   r  r  rP  difflibr  r   r   r   get_opcodes)rS   r  r  
signed_asmunsigned_asmr  r   r  signed_instrunsigned_instrsmr   r   r  rJ  rM  s                   rV   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???@	@ 	@rX   N)rw   rN   rx   ry   r  r7   r3   run_test_in_subprocessr  r  r  r|   rX   rV   r  r  L  s        
 "# # #J $%, %, %$ Z%,N $X$.A3-GHHH)( )( IH Z)(V  %X$.A3-GHHH=@ =@ IH Z=@ =@ =@rX   r  c                   $    e Zd ZdZd Zd Zd ZdS ) TestParforReductionSetNumThreadszCTest execution correctness on reductions with set_num_threads.
    c                     t           j        }d|z  |dz
  t          d          fd            }|                              } |          }|                     ||           d S )Nr   r   Tr   c                     d}t          |            t                    D ],}d|z  z   }t          |           t                      }||z  }-|S r  r   r   r   nthreadsr  r   
local_maskgntr  masks        rV   udtz6TestParforReductionSetNumThreads.test_add.<locals>.udt  a    CH%%%AYY  T\

+++%''s
JrX   r   r  r   r  r  rS   r  r  expectr  r  r  s        @@rV   test_addz)TestParforReductionSetNumThreads.test_add      $E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rX   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        rV   r  z6TestParforReductionSetNumThreads.test_mul.<locals>.udt1  r  rX   )r  r   r  r   r  r  r  s        @@rV   test_mulz)TestParforReductionSetNumThreads.test_mul*  s     6+,,E1u	t				 	 	 	 	 
		 T""c$ii,,,,,rX   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        rV   r  z6TestParforReductionSetNumThreads.test_max.<locals>.udtE  se    CH%%%AYY $ $T\

+++%''#smmJrX   r  r  s        @@rV   r!  z)TestParforReductionSetNumThreads.test_max@  r  rX   N)rw   rN   rx   rT  r  r  r!  r|   rX   rV   r  r    sK         - - -(- - -,- - - - -rX   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   r;  r  r   )r   r   r   s      rV   r   z<TestDiagnosticEnvVar.test_diagnostics_env_var1.<locals>.impl[  sB    Ha
333  AAaDDrX   zParallel Accelerator Optimizing)r  r  r4   r   r  r   )rS   r  r   
the_outputs       rV   test_diagnostics_env_var1z.TestDiagnosticEnvVar.test_diagnostics_env_var1W  s    14
/0 		&4     !  DFFF		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 __&&
7DDDDDs   $AAAN)rw   rN   rx   r3   r  r	  r|   rX   rV   r  r  U  s>        $X$&&E E '&E E ErX   r  __main__rZ   )rw  r  r:  r  r   rz   r  
subprocessr   r   r  	functoolsr   r  r   numpy.randomr   rp  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.typedr   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_machineryr0   r1   numba.core.typed_passesr2   numba.tests.supportr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   numba.core.extendingrA   numba.core.bytecoderB   rC   r  rn  rE   ro  r{   x86_onlyr  r  r   r   r   rj  rr  r  r  r   r  r  r  r  r  r  r  r  r@  r  r  r  r  rh  rq  r  r(  r  r  r  r  r  r4  r  r  rj  r  r  r  rw   mainr|   rX   rV   <module>r	     s
    				 				 



   



                           / / / / / / / /  " " " " " " " "        = = = = = = = = = = = = = = = = = = = =Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q " " " " " " " "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	 	 	 ^ ^ ^ ^ ^h ^ ^ ^B	       ? ? ?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, x x x x x/ x x xv! # # # # # # # #4 f% f% f% f% f% f% f% f%R	 "; "; "; "; "; "; "; ";J :M :M :M :M :M :M :M :Mz B9 B9 B9 B9 B9o B9 B9 B9J zD zD zD zD zD_ zD zD zDz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    {) {) {) {) {) {) {) {)z 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 rX   