+
    /iC                        ^ RI t ^ RIHt ^ RIt^ RIHtHtHt ^ RI	t	^ RI	H
t ^ RIHtHt ^ RIHtHtHt ^ RIHtHtHtHtHtHt ^ RIHt R	 tR
 t ! R R4      t ! R R4      t ! R R4      t  ! R R4      t!R t"R t#R# )    N)product)assert_allcloseassert_equalassert_)raises)
MapWrapper_ScalarFunctionWrapper)	csr_array	csc_array	lil_array)_adjust_scheme_to_boundsapprox_derivativecheck_derivativegroup_columns_eps_for_method_compute_absolute_step)rosenc                     . RO. RO. RO. RO. RO. RO. RO.p \         P                  \        \        \        3 F  pV! V 4      p\         P
                  ! ^4      p\         P                  ! . R	O4      p\        W#4      p\        WT4       . R
Op\         P                  ! . RO4      p\        W#4      p\        WT4       K  	  \        X4      p\        V4      p\        Wg4       R# )   N)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   )r   r   r   r   r   r   )r   r      r   r   r   )r   r            r   )r   r   r   r   r   r   )	npasarrayr
   r   r   arangearrayr   r   )	structure	transformAordergroups_truegroupsgroups_1groups_2s           `/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/optimize/tests/test__numdiff.pytest_group_columnsr'      s    I jj)Y	B	i 		!hh12q(V)"hh12q(V) C QHQH$    c                     \         P                  ! \         P                  4      P                  p R V R,          RV R,          RV R,          /pR Fu  p\	        \        \         P                  \         P                  V4      W,          4       \	        \        \         P                  \         P                  V4      W,          4       Kw  	  \         P                  ! \         P                  4      P                  p R V R,          RV R,          RV R,          /pR F  p\	        \        \         P                  \         P                  V4      W,          4       \	        \        \         P                  \         P                  V4      W,          4       \	        \        \         P                  \         P                  V4      W,          4       K  	  R# )2-point      ?3-pointcsNUUUUUU?r*   r,   r-   )r   finfofloat64epsr   r   
complex128float32)EPSrelative_stepmethods      r&   test_correct_fp_epsr8   .   s@   
((2::

"
"CSsSz38%M /BJJ

F;!	# 	BMM2==&A!	
	 / ((2::

"
"CSsSz38%M /BJJ

F;!	
 	BJJ

F;!	
 	BJJ

F;!	
 /r(   c                   2   a  ] tR t^Rt o R tR tR tRtV tR# )TestAdjustSchemeToBoundsc                
   \         P                  ! ^4      p\         P                  ! ^R4      p\         P                  ! V4      p\         P                  ! V4      pVP	                  \         P
                  ) 4       VP	                  \         P
                  4       \        W^RW44      w  rV\        WR4       \        \         P                  ! V4      4       \        W^RW44      w  rV\        WR4       \        \         P                  ! V4      4       \        W^RW44      w  rV\        WR4       \        \         P                  ! V( 4      4       \        W^RW44      w  rV\        WR4       \        \         P                  ! V( 4      4       R# )r   {Gz?1-sided2-sidedN)
r   zerosfull
empty_likefillinfr   r   r   all)selfx0h	inf_lower	inf_upper
h_adjusted	one_sideds   &      r&   test_no_bounds'TestAdjustSchemeToBounds.test_no_boundsS   s   XXa[GGAtMM"%	MM"%	wrvv 81i!7

&y!" 81i!7

&y!" 81i!7

&	z"# 81i!7

&	z"#r(   c                   \         P                  ! . RO4      p\         P                  ! ^4      ) p\         P                  ! ^4      p\         P                  ! . RO4      R,          p\        W^RW#4      w  rV\	        WT4       \        W^RW#4      w  rV\	        V\         P                  ! . RO4      R,          4       \        W^RW#4      w  rW\	        V\         P
                  ! V4      4       \        \         P                  ! V( 4      4       \        W^RW#4      w  rW\	        V\         P                  ! . RO4      R,          4       \        V\         P                  ! . RO4      4       R# )	        皙?r=   r>   N)rO   g333333?g333333)r   r   )r   rQ   r   )FTT)	r   r   onesr   r   absr   rD   r   )rE   rF   lbubrG   rJ   _rK   s   &       r&   test_with_bound(TestAdjustSchemeToBounds.test_with_boundo   s   XX()ggaj[WWQZHHZ 4'09bM

&09bM

BHHZ$84$?@ 81i!)

BFF1I.	z"# 81i!)

BHHZ$84$?@Y)< =>r(   c                   \         P                  ! R
R
.4      p\         P                  ! RR.4      p\         P                  ! RR .4      p\         P                  ! RR.4      p\        W4^RW4      w  rV\        V\         P                  ! RR.4      4       \        W4^RW4      w  rV\        V\         P                  ! RR
.4      4       \        W4^RW4      w  rW\        V\         P                  ! R R
.4      4       \	        V\         P                  ! RR.4      4       \        W4^RW4      w  rW\        V\         P                  ! RR.4      4       \	        V\         P                  ! RR.4      4       R	# )gQ?g?rO   r=   g?r>   FTgQ?NgQ皙gQgQ)r   r   r   r   r   )rE   rT   rU   rF   rG   rJ   rV   rK   s   &       r&   test_tight_bounds*TestAdjustSchemeToBounds.test_tight_bounds   s$   XXuen%XXtTl#XXsDk"HHdD\"09bM

BHHdE]$;<09bM

BHHeU^$<= 81i!)

BHHdE]$;<Y% 78 81i!)

BHHeV_$=>Y% 78r(    N)	__name__
__module____qualname____firstlineno__rL   rW   r[   __static_attributes____classdictcell____classdict__s   @r&   r:   r:   R   s     $8?,9 9r(   r:   c                   <  a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR(R ltR)R ltR tR tR tR tR tR tR tR t]P4                  P7                  R4      R 4       tR tR tR tR t R t!R t"R t#R t$R  t%R! t&R" t'R# t(R$ t)R% t*R&t+V t,R'# )*TestApproxDerivativesDensec                .    \         P                  ! V4      # Nr   sinhrE   xs   &&r&   fun_scalar_scalar,TestApproxDerivativesDense.fun_scalar_scalar       wwqzr(   c                .    \         P                  ! V4      # ri   r   coshrl   s   &&r&   jac_scalar_scalar,TestApproxDerivativesDense.jac_scalar_scalar   rp   r(   c                    \         P                  ! V^ ,          ^,          \         P                  ! V^ ,          4      \         P                  ! V^ ,          4      .4      # r   r   r   tanexprl   s   &&r&   fun_scalar_vector,TestApproxDerivativesDense.fun_scalar_vector   8    xx1q"&&1,qt=>>r(   c                    \         P                  ! ^V^ ,          ,          \         P                  ! V^ ,          4      R,          \         P                  ! V^ ,          4      .4      P	                  R^4      # r   rQ   r   r   cosrz   reshaperl   s   &&r&   jac_scalar_vector,TestApproxDerivativesDense.jac_scalar_vector   N    xx1Xrvvad|r)266!A$<8::A'"a.	Ir(   c                    \         P                  ! V^ ,          V^,          ,          4      \         P                  ! V^ ,          4      ,          # rw   r   sinlogrl   s   &&r&   fun_vector_scalar,TestApproxDerivativesDense.fun_vector_scalar   .    vvadQqTk"RVVAaD\11r(   c                    \         P                  ! V^,          \         P                  ! V4      \         P                  ! V4      .4      # r   rx   rl   s   &&r&   wrong_dimensions_fun/TestApproxDerivativesDense.wrong_dimensions_fun   s,    xxArvvay"&&)455r(   c           	        \         P                  ! V^,          \         P                  ! V^ ,          V^,          ,          4      ,          \         P                  ! V^ ,          4      ,          \         P                  ! V^ ,          V^,          ,          4      V^ ,          ,          ,           V^ ,          \         P                  ! V^ ,          V^,          ,          4      ,          \         P                  ! V^ ,          4      ,          .4      # r   r   r   r   r   r   rl   s   &&r&   jac_vector_scalar,TestApproxDerivativesDense.jac_vector_scalar       xxaD266!A$1+&&!5FF1Q4!A$;!A$&'aD266!A$1+&&!5
  	r(   c                   \         P                  ! V^ ,          \         P                  ! V^,          4      ,          V^,          \         P                  ! V^ ,          4      ,          V^ ,          ^,          V^,          R,          ,          .4      # r         ࿩r   r   r   r   rl   s   &&r&   fun_vector_vector,TestApproxDerivativesDense.fun_vector_vector   `    xxaD266!A$<aD266!A$<aDAI!$
  	r(   c                0   V^*8X  g   Q h\         P                  ! V^ ,          \         P                  ! V^,          4      ,          V^,          \         P                  ! V^ ,          4      ,          V^ ,          ^,          V^,          R,          ,          .4      # )=Used to test passing custom arguments with check_derivative()r   r   rE   rm   args   &&&r&   fun_vector_vector_with_arg5TestApproxDerivativesDense.fun_vector_vector_with_arg   sl    byyxxaD266!A$<aD266!A$<aDAI!$
  	r(   c                   \         P                  ! \         P                  ! V^,          4      V^ ,          \         P                  ! V^,          4      ,          .V^,          ) \         P                  ! V^ ,          4      ,          \         P                  ! V^ ,          4      .^V^ ,          ^,          ,          V^,          R,          ,          RV^ ,          ^,          ,          V^,          R,          ,          ..4      # r   r         r   rl   s   &&r&   jac_vector_vector,TestApproxDerivativesDense.jac_vector_vector       xxVVAaD\1Q4"&&1,./dURVVAaD\!266!A$<01]QqTT\)4!A$!)+;addl+JK
  	r(   c                   V^*8X  g   Q h\         P                  ! \         P                  ! V^,          4      V^ ,          \         P                  ! V^,          4      ,          .V^,          ) \         P                  ! V^ ,          4      ,          \         P                  ! V^ ,          4      .^V^ ,          ^,          ,          V^,          R,          ,          RV^ ,          ^,          ,          V^,          R,          ,          ..4      # )r   r   r   r   r   s   &&&r&   jac_vector_vector_with_arg5TestApproxDerivativesDense.jac_vector_vector_with_arg   s    byyxxVVAaD\1Q4"&&1,./dURVVAaD\!266!A$<01]QqTT\)4!A$!)+;addl+JK
  	r(   c                    \         P                  ! \         P                  ! W!^ ,          ,          4      \         P                  ! W1^,          ,          4      .4      # rw   r   r   rz   rE   rm   c0c1s   &&&&r&   fun_parametrized+TestApproxDerivativesDense.fun_parametrized   s4    xxqT	*BFF2!9,=>??r(   c           
         \         P                  ! V\         P                  ! W!^ ,          ,          4      ,          ^ .^ V\         P                  ! W1^,          ,          4      ,          ..4      # rw   r   r   s   &&&&r&   jac_parametrized+TestApproxDerivativesDense.jac_parametrized   sP    xx"&&d##Q'RVVB1I&&'
  	r(   c                \    \         P                  ! V4      R 8:  d   V# \         P                  # ):0yE>r   rS   nanrl   s   &&r&   fun_with_nan'TestApproxDerivativesDense.fun_with_nan   s     FF1I%q12661r(   c                \    \         P                  ! V4      R 8:  d   R# \         P                  # )r         ?r   rl   s   &&r&   jac_with_nan'TestApproxDerivativesDense.jac_with_nan   s     ffQi4's3RVV3r(   c                    \         P                  ! V^ ,          V^,          ,          \         P                  ! V^ ,          V^,          ,          4      .4      # rw   )r   r   r   rl   s   &&r&   fun_zero_jacobian,TestApproxDerivativesDense.fun_zero_jacobian   s7    xx1!bffQqTAaD[&9:;;r(   c           
     6   \         P                  ! V^,          V^ ,          .V^,          ) \         P                  ! V^ ,          V^,          ,          4      ,          V^ ,          ) \         P                  ! V^ ,          V^,          ,          4      ,          ..4      # r   )r   r   r   rl   s   &&r&   jac_zero_jacobian,TestApproxDerivativesDense.jac_zero_jacobian   so    xxqT1Q4LdURVVAaD1Q4K((1Q4%"&&1!2E*EF
  	r(   c                v    \         P                  ! V4      P                  4       p\        P                  ! V4      # ri   )r   r   itemmathrz   )rE   rm   xps   && r&   jac_non_numpy(TestApproxDerivativesDense.jac_non_numpy   s(     ZZ]!xx|r(   c                   R p\        V P                  VRR7      p\        V P                  V4      p\        V P                  VRR7      pV P                  V4      p\        W%RR7       \        W5RR7       \        WERR7       R# )	r   r*   r7   r-   ư>rtol&.>-q=Nr   rn   rt   r   rE   rF   
jac_diff_2
jac_diff_3
jac_diff_4jac_trues   &     r&   test_scalar_scalar-TestApproxDerivativesDense.test_scalar_scalar   su    &t'='=r.79
&t'='=rB
&t'='=r.24
))"-
48
48
59r(   c                   R p\        V P                  VRRR7      p\        V P                  VRR7      p\        V P                  VRRR7      pV P                  V4      p\        W%RR7       \        W5RR7       \        WER	R7       R
# )r   r*   "\O>r7   abs_step)r   r-   r   r   r   r   Nr   r   s   &     r&   test_scalar_scalar_abs_step6TestApproxDerivativesDense.test_scalar_scalar_abs_step  s    &t'='=r.7'K
&t'='=r079
&t'='=r.2WF
))"-
48
48
59r(   c           	        R p\        ^4      ;_uu_ 4       p\        V P                  VRVR7      pRRR4       \        V P                  V\        R7      p\        V P                  VRRR7      pV P	                  \
        P                  ! V4      4      p\        XVRR7       \        WFRR7       \        WVR	R7       R#   + '       g   i     L; i)
r+   r*   r7   workersN)r   r-   r   r   r   r   )r   r   r{   mapr   r   
atleast_1dr   )rE   rF   mapperr   r   r   r   s   &      r&   test_scalar_vector-TestApproxDerivativesDense.test_scalar_vector  s    ]]f*4+A+A22;VMJ  't'='=r3O
&t'='=r.2DB
))"--*;<
H48
48
59 ]s   B<<C	g      @c           
        . R
Op\        ^4      ;_uu_ 4       p\        \        VRVRR7      w  r4\        \        VVRR7      w  rVRRR4       \        \        VR^RR7      w  rx\        \        4      p	\        WRRR7      w  r\	        VR,          V	P
                  4       ^ V	n        \        WRR	7      w  r\	        VR,          V	P
                  4       ^ V	n        \        WRRR7      w  r\	        VR,          V	P
                  4       \	        XR,          VR,          4       \	        XR,          VR,          4       \	        VR,          VR,          4       \	        XV
4       \	        XV4       \	        W~4       R#   + '       g   i     EL=; i)r+   r*   T)r7   r   full_output)r   r   Nr-   )r7   r   nfev)r   )r+   g      ?       @)r   r   r   r	   r   r   )rE   rF   r   md2mdct2md3mdct3md4mdct4sfrd2dct2d3dct3d4dct4s   &               r&   !test_workers_evaluations_and_nfev<TestApproxDerivativesDense.test_workers_evaluations_and_nfev  s=    ]]f*5"2;V7;=JC +5"39tMJC	  'ub.2A379
 %U+$SYDQT&\388,$S$?T&\388,$STtLT&\388,U6]DL1U6]DL1U6]DL1S"S"S9 ]]s   ,E88F		c                2   \         P                  ! R R	.4      p\        V P                  VRR7      p\        V P                  V4      p\        V P                  VRR7      pV P	                  V4      p\        W%RR7       \        W5RR7       \        WERR7       R# )
      Y@r*   r   r-   r   r   Hz>r   Nr   )r   r   r   r   r   r   r   s   &     r&   test_vector_scalar-TestApproxDerivativesDense.test_vector_scalar?  s    XXudm$&t'='=r.79
&t'='=rB
&t'='=r.24
))"-
48
48
59r(   c                X   \         P                  ! R R.4      p\        V P                  VRRR7      p\        V P                  VR\         P                  R7      p\        V P                  VRRR7      pV P                  V4      p\        W%RR7       \        W5RR7       \        WER	R7       R
# )r   r*   r   r   )r   rel_stepr-   r   r   A:)>r   Nr   )r   r   r   r   rC   r   r   r   s   &     r&   test_vector_scalar_abs_step6TestApproxDerivativesDense.test_vector_scalar_abs_stepK  s    XXudm$&t'='=r.7'K
&t'='=r07"&&J
&t'='=r.2WF
))"-
48
48
59r(   c           	        \         P                  ! RR.4      p\        V P                  VRR7      p\        V P                  V4      p\	        ^4      ;_uu_ 4       p\        V P                  VRVR7      pRRR4       V P                  V4      p\        W&RR7       \        W6R	R7       \        XVR
R7       R#   + '       g   i     LK; i)r   皙?r*   r   r-   r   Nh㈵>r   r   r         Y)r   r   r   r   r   r   r   )rE   rF   r   r   r   r   r   s   &      r&   test_vector_vector-TestApproxDerivativesDense.test_vector_vectorY  s    XXvsm$&t'='=r.79
&t'='=rB
]]f*4+A+A226HJ  ))"-
48
48
H59 ]s   B77C	c                    R p\        \        \        V P                  V4       V P                  \        P
                  ! V4      4      p\        \        \        V P                  WR7       R# )r   )f0N)assert_raisesRuntimeErrorr   r   r   r   
ValueError)rE   rF   r  s   &  r&   test_wrong_dimensions0TestApproxDerivativesDense.test_wrong_dimensionsf  sP    l$5//	5&&r}}R'89j"3//	<r(   c                    \         P                  ! RR .4      p\        V P                  VRRR7      p\        V P                  VRR7      pV P	                  V4      p\        W$RR7       \        W4RR7       R# )	rP   r*   g-C6?)r7   r  )r  r<   r   NrZ   )r   r   r   r   r   r   )rE   rF   r   r   r   s   &    r&   test_custom_rel_step/TestApproxDerivativesDense.test_custom_rel_stepn  si    XXtSk"&t'='=r.7$H
&t'='=r046
))"-
48
48r(   c                   \         P                  ! R R .4      pRpR pRpRpV P                  WVR7      p\         P                  ! RR.4      pV P                  WV4      p\	        V P                  VRVWb3\        VR7      WE3R7      p	\	        V P                  WWb3\        VR7      WE3R7      p
\        WRR	7       \        WR
R	7       R# )r   rO   r   )r   r   r   r*   )r7   r  r  argskwargsbounds)r  r  r  r  r  r   r   N      gư)r   r   r   r   r   dictr   )rE   rF   r   r   rT   rU   r  r  r   r   r   s   &          r&   test_options'TestApproxDerivativesDense.test_optionsx  s    XXsCj!""2b"188UDM*((4&!!2i(dbk2(D
 '!!2dbk2(D
 	
48
48r(   c                v   \         P                  ! ^4      ) p\         P                  ! ^4      p\         P                  ! R	R.4      p\        \        \
        V P                  W1V3R7       \         P                  ! R
R.4      p\        V P                  VRW3R7      pV P                  V4      p\        WERR7       R# )r   r	  r  r   r*   r7   r  r   r   Ng       r  )	r   rR   r   r  r  r   r   r   r   )rE   rT   rU   rF   jac_diffr   s   &     r&   test_with_bounds_2_point3TestApproxDerivativesDense.test_with_bounds_2_point  s    ggaj[WWQZXXtSk"j"3,,bb	C XXtSk"$T%;%;R,5rhH))"-6r(   c                    \         P                  ! R R .4      p\         P                  ! RR.4      p\         P                  ! R R.4      pV P                  V4      p\        V P                  V4      p\        WTRR7       \        V P                  VV\         P                  3R7      p\        WTRR7       \        V P                  V\         P                  ) V3R7      p\        WTRR7       \        V P                  VW3R7      p\        WTRR7       R# )r   r   r   r   r!  N)r   r   r   r   r   r   rC   )rE   rT   rU   rF   r   r#  s   &     r&   test_with_bounds_3_point3TestApproxDerivativesDense.test_with_bounds_3_point  s    XXsCj!XXsCj!XXsCj!))"-$T%;%;R@6$T%;%;R-/L:6$T%;%;R.0ffWbM;6$T%;%;R-/H66r(   c                   \         P                  ! R R .4      pVR,
          pVR,           pV P                  V4      p\        V P                  VRW#3R7      p\        WTRR7       \        V P                  VRRW#3R7      p\        WTRR7       \        V P                  WV3R7      p\        WTRR7       \        V P                  VRW#3R	7      p\        WERR7       R
# )      $@r  g&.!>r*   r"  r   r   r7   r  r  r!  r  r  N)r   r   r   r   r   r   )rE   rF   rT   rU   r   r#  s   &     r&   r[   ,TestApproxDerivativesDense.test_tight_bounds  s    XXtTl#$Y$Y))"-$""By"K6$""By2(, 	6$""BBx96$""BrhH6r(   c                   R	pR pRpV P                  V4      p\        V P                  VRRW3R7      p\        V P                  VRW3R7      p\        WTRR7       \        WdRR7       R pV P                  V4      p\        V P                  VRRW3R7      p\        V P                  VRW3R7      p\        WTRR7       \        WdRR7       R# )
r   rO   r*   r   r+  r,  r   r   N:0yE)r   r   r   r   )rE   rT   rU   rF   r   r   r   s   &      r&   test_bound_switches.TestApproxDerivativesDense.test_bound_switches  s    $$R(&r)d8
 'rD"C

48
48$$R(&r)d8
 'rD"C

48
48r(   c                   R pV P                  V4      p\        V P                   VRR7      p\        V P                   V4      p\        W2RR7       \        WBRR7       \        \        \        V P                   V3/ \        RR7      B  R# )r   r*   r   r   r   r   r-   N)r   r   r   r  	TypeErrorr  )rE   rF   r   r   r   s   &    r&   test_non_numpy)TestApproxDerivativesDense.test_non_numpy  sz    %%b)&t'9'92.79
&t'9'92>

48
48 	i!2D4F4F 	+D)	+r(   c                *  aaaa \         P                  P                  ^4      pR oV3R lo\         P                  ! ^ ^^d\         P                  R7      oVP                  ^d\         P                  R7      o\         P
                  ! RR.4      p\        SVRSS3R7      p\        SVP                  \         P                  4      RSS3R7      pS! VSS4      P                  \         P                  8X  g   Q h\        WCRR	7       VVV3R
 lp\        WRP                  \         P                  4      RR7      p\        WCRR	7       R pR pR pR p	\         P                  \         P                  \         P                  3 F  p
\         P                  ! V
4      P                  p\         P
                  ! R4      P                  V
4      p\        RW! V4      R4      pV	! WWhV4      p\        WlRVR7      V! V4      ,
          o\        S4      V8  d   K  Q h	  R# )r   c                 >    V ^ ,          V ^,          V,          ,           # rw   r]   )prm   s   &&r&   func0TestApproxDerivativesDense.test_fp.<locals>.func  s    Q4!A$(?"r(   c                 "   < S! W4      V,
          # ri   r]   )r8  rm   yr9  s   &&&r&   err/TestApproxDerivativesDense.test_fp.<locals>.err  s    :>!r(   dtype)sizer@  r   r*   )r7   r  gMbP?)atolc                    < V P                   \        P                  8X  g   Q hS! V SS4      P                  \        P                  4      # ri   )r@  r   r4   astype)r8  r=  rm   r<  s   &r&   err_fp324TestApproxDerivativesDense.test_fp.<locals>.err_fp32  s6    77bjj(((q!Q<&&rzz22r(   r   c                 .    \         P                  ! V 4      # ri   r   r   rm   s   &r&   f-TestApproxDerivativesDense.test_fp.<locals>.f      66!9r(   c                 .    \         P                  ! V 4      # ri   )r   r   rI  s   &r&   g-TestApproxDerivativesDense.test_fp.<locals>.g	  rL  r(   c                 0    \         P                  ! V 4      ) # ri   rH  rI  s   &r&   hess0TestApproxDerivativesDense.test_fp.<locals>.hess  s    FF1I:r(   c           
      `   V ^,          \        \        P                  ! V! V4      4      \        P                  ! V! W,           4      4      4      ,          pW@,          \        \        P                  ! V! V4      4      \        P                  ! V! W,           4      4      4      ,          pWV,           # r   )maxr   rS   )rG   rF   rJ  rQ  r5   t0t1s   &&&&&  r&   	calc_atol5TestApproxDerivativesDense.test_fp.<locals>.calc_atol  sj    QRVVDH-rvvd26l/CDDB 3rvvae}bffQrvY.?@@B7Nr(   Nr   r  )r   randomdefault_rnglinspacer1   r   r   rD  r4   r@  r   float16r0   r2   r   rS   )rE   rngp0jac_fp64jac_fprE  rJ  rN  rQ  rW  r@  r5   rF   rG   rB  r=  r9  rm   r<  s   &              @@@@r&   test_fp"TestApproxDerivativesDense.test_fp  s    ii##A&	#	" KK1c4JJCrzzJ2XXtTl#$S"YaVL #3		"**(=*31a&B2q!}""bjj000t4	3 #8YYrzz-B*35t4				 jj"**bjj9E((5/%%C#%%e,B&tR2	BAQAS1D#A)-.023B%8Cs8d?"? :r(   c                   \         P                  ! R^
.4      p\        V P                  V P                  V4      p\        VR8  4       \        V P                  V P                  V4      p\        VR8  4       \         P                  ! RR.4      p\        V P                  V P                  V4      p\        V^ 8H  4       \        V P                  V P                  V4      p\        V^ 8H  4       R# )r*  r   r   rO   N      $)r   r   r   r   r   r   r   r   rE   rF   accuracys   &  r&   test_check_derivative0TestApproxDerivativesDense.test_check_derivative   s    XXubk"#D$:$:$($:$:B@4 #D$:$:$($:$:B@4 XXsCj!#D$:$:$($:$:B@A#D$:$:$($:$:B@Ar(   c                    \         P                  ! R^
.4      p\        V P                  V P                  VR^*/R7      p\        VR8  4       R# )r*  r   )r  r   Nrd  )r   r   r   r   r   r   re  s   &  r&   !test_check_derivative_with_kwargs<TestApproxDerivativesDense.test_check_derivative_with_kwargs1  sG    XXubk"#D$C$C$($C$C$&,12;8 	4 r(   r]   N)r   )rP   )-r^   r_   r`   ra   rn   rt   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pytestmark	fail_slowr   r  r  r  r  r  r  r$  r'  r[   r0  r4  ra  rg  rj  rb   rc   rd   s   @r&   rg   rg      s     ?I26@24<
::: [[3    D
:::<99$77,7(9.+8#t"! !r(   rg   c                      a  ] tR tRt o R tR tR tR t]P                  P                  ^4      R 4       tR tR tR	 tR
tV tR# )TestApproxDerivativeSparsei:  c                N   \         P                  P                  R 4      V n        ^2V n        R^\         P
                  ! V P                  4      ,           ,          V n        R^\         P
                  ! V P                  4      ,           ,          V n        \         P                  ! V P                  4      V n	        RV P                  R,          ,          V P                  R&   RV P                  R,          ,          V P                  R&   V P                  V P                  4      V n        R# )i7rP   NNr   :r   Nr   NrZ   gP?)r   rY  rZ  r]  nr   rT   rU   emptyrF   jacJ_true)rE   s   &r&   setup_method'TestApproxDerivativeSparse.setup_method<  s    99((3!bii//0RYYtvv../((466" DGGCL0!TWWT]2hhtww'r(   c                    VR ,          ^,          VRR ^,          ,
          p\         P                  ! ^ ^V,          34      \         P                  ! ^V,          ^ 34      ,           # ):r   NNNrQ   )r   hstack)rE   rm   es   && r&   funTestApproxDerivativeSparse.funG  sK    bE1Hq"vqy yy!QU$ryy!a%'<<<r(   c                "   VP                   p\        P                  ! W"34      pRV^ ,          ,          VR&   ^V^,          ^,          ,          VR&   \        ^V^,
          4       Fz  pRW^,
          ,          ,          W4V^,
          3&   ^	W,          ^,          ,          ^W,          ,          ,
          W4V3&   ^W^,           ,          ^,          ,          W4V^,           3&   K|  	  ^	VR,          ^,          ,          VR&   RVR,          ,          VR&   V# )	r   r   r   r   r   irQ   rQ   rQ   r   rQ   r   )rA  r   r?   range)rE   rm   rs  Jis   &&   r&   ru  TestApproxDerivativeSparse.jacK  s    FFHHaVqt)$adAg+$q!a%Aq1v+AQhK!$'kAH,AdGa!fai-AQhK ! "qL&	2J&	r(   c                    \         P                  ! W3\        R 7      p^VR&   ^VR&   \        ^V^,
          4       F  p^W#V^,
          V^,           13&   K  	  ^VR&   ^VR&   V# )r?  r  r  r  r  )r   r?   intr  )rE   rs  r    r  s   &&  r&   r   $TestApproxDerivativeSparse.structureY  si    HHaV3'$$q!a%A!"AQAo !&	&	r(   c                   V P                  V P                  4      p\        P                  ! V P                  4      p\	        W4      pV P
                  P                  V4       \	        W4      p\        ^4      ;_uu_ 4       p\        . R	OW4.\        P                  ) V P                  .\        P                  V P                  .\        V.4       F  w  rgrp
\        V P                  V P                  VW3W3V
R7      p\!        \#        V\$        4      4       \'        VP)                  4       V P*                  RR7       \        P,                  ! V P                  R4      pVR;;,          R
,          uu&   \        V P                  V P                  VWV3V
R7      p\'        VP)                  4       V P*                  RR7       K  	  RRR4       R#   + '       g   i     R# ; i)r   )r7   r  sparsityr   r   r   r   rr  )r7   r  r  r   r
  Nr/   rQ   )r   rs  r   r   r   r]  shuffler   r   rC   rT   rU   r   r   r|  rF   r   
isinstancer
   r   toarrayrv  	full_like)rE   r    r!   r$   r%   r   r7   r#   lumfr  r  s   &            r&   test_all#TestApproxDerivativeSparse.test_alld  sS   NN466"		$&&! * *]]f,3082FffWdgg&(9C=-J(b &dhh./Vqk.02 
1i01		T[[tD<<6#%dhh/7f+.02  		T[[tD-J ]]]s    EGG	c                    V P                  V P                  4      p\        V P                  V P                  VR 7      p\        VP                  4       V P                  RR7       R# ))r  r   r   N)r   rs  r   r|  rF   r   r  rv  )rE   r    r  s   &  r&   test_no_precomputed_groups5TestApproxDerivativeSparse.test_no_precomputed_groups}  s@    NN466"dhh!<		T[[t<r(   c                   \         P                  ! V P                  V P                  3\        R 7      p\         P                  ! V P                  4      pR Fe  p\        V P                  V P                  VR7      p\        V P                  V P                  W3VR7      p\        WEP                  4       RRR7       Kg  	  R# )r?  r   )r  r7   gV瞯<gVs<)r   rB  Nr/   )
r   rR   rs  r  r   r   r|  rF   r   r  )rE   r   r#   r7   J_denseJ_sparses   &     r&   test_equivalence+TestApproxDerivativeSparse.test_equivalence  s    GGTVVTVV,C8	466"2F'$''&IG($''Y,?PHG%5%5%7!&U4	 3r(   c                0  a  V 3R  lp\        S P                  VS P                  S P                  S P                  3R7      p\        VR8  4       \        S P                  VS P                  S P                  S P                  3R7      p\        VR8  4       R# )c                 8   < \        SP                  V 4      4      # ri   )r
   ru  )rm   rE   s   &r&   ru  =TestApproxDerivativeSparse.test_check_derivative.<locals>.jac  s    TXXa[))r(   r!  r   N)r   r|  rF   rT   rU   r   )rE   ru  rf  s   f  r&   rg  0TestApproxDerivativeSparse.test_check_derivative  sr    	* $DHHc477,0GGTWW+=?4 #DHHc477,0GGTWW+=?4 r(   )rv  rT   rs  r]  rU   rF   N)r^   r_   r`   ra   rw  r|  ru  r   rl  rm  rn  r  r  r  rg  rb   rc   rd   s   @r&   rp  rp  :  sR     	(=	 [[1E E0=
4
! 
!r(   rp  c                   n   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tRtV tR# )"TestApproxDerivativeLinearOperatori  c                .    \         P                  ! V4      # ri   rj   rl   s   &&r&   rn   4TestApproxDerivativeLinearOperator.fun_scalar_scalar  rp   r(   c                .    \         P                  ! V4      # ri   rr   rl   s   &&r&   rt   4TestApproxDerivativeLinearOperator.jac_scalar_scalar  rp   r(   c                    \         P                  ! V^ ,          ^,          \         P                  ! V^ ,          4      \         P                  ! V^ ,          4      .4      # rw   rx   rl   s   &&r&   r{   4TestApproxDerivativeLinearOperator.fun_scalar_vector  r}   r(   c                    \         P                  ! ^V^ ,          ,          \         P                  ! V^ ,          4      R,          \         P                  ! V^ ,          4      .4      P	                  R^4      # r   r   rl   s   &&r&   r   4TestApproxDerivativeLinearOperator.jac_scalar_vector  r   r(   c                    \         P                  ! V^ ,          V^,          ,          4      \         P                  ! V^ ,          4      ,          # rw   r   rl   s   &&r&   r   4TestApproxDerivativeLinearOperator.fun_vector_scalar  r   r(   c           	        \         P                  ! V^,          \         P                  ! V^ ,          V^,          ,          4      ,          \         P                  ! V^ ,          4      ,          \         P                  ! V^ ,          V^,          ,          4      V^ ,          ,          ,           V^ ,          \         P                  ! V^ ,          V^,          ,          4      ,          \         P                  ! V^ ,          4      ,          .4      # r   r   rl   s   &&r&   r   4TestApproxDerivativeLinearOperator.jac_vector_scalar  r   r(   c                   \         P                  ! V^ ,          \         P                  ! V^,          4      ,          V^,          \         P                  ! V^ ,          4      ,          V^ ,          ^,          V^,          R,          ,          .4      # r   r   rl   s   &&r&   r   4TestApproxDerivativeLinearOperator.fun_vector_vector  r   r(   c                   \         P                  ! \         P                  ! V^,          4      V^ ,          \         P                  ! V^,          4      ,          .V^,          ) \         P                  ! V^ ,          4      ,          \         P                  ! V^ ,          4      .^V^ ,          ^,          ,          V^,          R,          ,          RV^ ,          ^,          ,          V^,          R,          ,          ..4      # r   r   rl   s   &&r&   r   4TestApproxDerivativeLinearOperator.jac_vector_vector  r   r(   c                   R p\        V P                  VRRR7      p\        V P                  VRR7      p\        V P                  VRRR7      pV P                  V4      p\        P                  P                  R4      p\        ^
4       F  pVP                  R^
RR7      p\        VP                  V4      WX,          RR	7       \        VP                  V4      WX,          R
R	7       \        VP                  V4      WX,          R
R	7       K  	  R# )r   r*   Tr7   as_linear_operatorr  r-      nV)rA  r
  r   h㈵>Nr   )
r   rn   rt   r   rY  rZ  r  uniformr   dot	rE   rF   r   r   r   r   r]  r  r8  s	   &        r&   r   5TestApproxDerivativeLinearOperator.test_scalar_scalar  s    &t'='=r.7:>@
 't'='=r:>@
&t'='=r.2:>@
 ))"-ii##N3rAC$/AJNN1-xz!%'JNN1-xz!%'JNN1-xz!%' r(   c                z   R p\        V P                  VRRR7      p\        V P                  VRR7      p\        V P                  VRRR7      pV P                  \        P                  ! V4      4      p\        P
                  P                  R4      p\        ^
4       F  pVP                  R^
RR7      p\        VP                  V4      VP                  V4      RR	7       \        VP                  V4      VP                  V4      R
R	7       \        VP                  V4      VP                  V4      R
R	7       K  	  R# )r+   r*   Tr  r  r-   r  r  r
  r   r  Nr  r   )r   r{   r   r   r   rY  rZ  r  r  r   r  r  s	   &        r&   r   5TestApproxDerivativeLinearOperator.test_scalar_vector  s   &t'='=r.7:>@
 't'='=r:>@
&t'='=r.2:>@
 ))"--*;<ii##N3rAC$/AJNN1-x||A!%'JNN1-x||A!%'JNN1-x||A!%' r(   c           	     
   \         P                  ! R R.4      p\        V P                  VRRR7      p\        V P                  VRR7      p\        V P                  VRRR7      pV P	                  V4      p\         P
                  P                  R4      p\        ^
4       F  pVP                  R^
VP                  R7      p\        VP                  V4      \         P                  ! VP                  V4      4      RR	7       \        VP                  V4      \         P                  ! VP                  V4      4      R
R	7       \        VP                  V4      \         P                  ! VP                  V4      4      RR	7       K  	  R# )r   r*   Tr  r  r-   r  r  r
  r   r  r   Nr   r  )r   r   r   r   r   rY  rZ  r  r  shaper   r  r   r  s	   &        r&   r  5TestApproxDerivativeLinearOperator.test_vector_scalar  s+   XXudm$&t'='=r.7:>@
 't'='=r:>@
&t'='=r.2:>@
 ))"-ii##N3rAC"((3AJNN1-r}}X\\!_/M!%'JNN1-r}}X\\!_/M!%'JNN1-r}}X\\!_/M!%' r(   c                   \         P                  ! RR.4      p\        V P                  VRRR7      p\        V P                  VRR7      p\        V P                  VRRR7      pV P	                  V4      p\         P
                  P                  R4      p\        ^
4       F  pVP                  R^
VP                  R7      p\        VP                  V4      VP                  V4      R	R
7       \        VP                  V4      VP                  V4      RR
7       \        VP                  V4      VP                  V4      RR
7       K  	  R# )r   r	  r*   Tr  r  r-   r  r  r
  r   r   r   Nr  r  )r   r   r   r   r   rY  rZ  r  r  r  r   r  r  s	   &        r&   r  5TestApproxDerivativeLinearOperator.test_vector_vector  s   XXvsm$&t'='=r.7:>@
 't'='=r:>@
&t'='=r.2:>@
 ))"-ii##N3rAC"((3AJNN1-x||ATJJNN1-x||ATJJNN1-x||ATJ	 r(   c           	         \         P                  ! RR.4      p\        \        \        V P
                  VR^\         P                  3R7       R# )r   r	  r*   r"  Nr  )r   r   r  r  r   r   rC   )rE   rF   s   & r&   test_exception1TestApproxDerivativeLinearOperator.test_exception  s9    XXvsm$j"3,,b&266{	<r(   r]   N)r^   r_   r`   ra   rn   rt   r{   r   r   r   r   r   r   r   r  r  r  rb   rc   rd   s   @r&   r  r    sM     ?I2'*'*'*K$< <r(   r  c                     R  p \        V RR.RRR7      p\        VRR.4       \        V RR.RR	R7      p\        VRR.4       \        V RR.RRR.R7      p\        VRR.4       \        V RR.RRR	.R7      p\        VRR.4       \        V RR.RR	R.R7      p\        VRR.4       \        V RR.RR\        P                  ) R3R7      p\        VRR.4       \        V RR.RR	R\        P                  3R7      p\        VRR.4       R# )
c                     \         P                  ! V ^ ,          ^,           4      ) \         P                  ! V ^,          ^,           4      ,           # rw   )r   rS   rI  s   &r&   rJ  "test_absolute_step_sign.<locals>.f!  s2    qtax  266!A$(#333r(   r*   r   r   r   )r7   r   r  NrQ   r  r/  )r   r   r   rC   )rJ  grads     r&   test_absolute_step_signr    s;   4 QRTJDD4+& QRUKDD3+& 	B8ItD D4+& 	B8IuD D4,'	B8ID D3*% 	B8I}D D3+&	B8Ir266lD D4+&r(   c                  <   . ROp \         P                  ! . RO4      p\         P                  ! \         P                  4      P                  pR VR,          RVR,          RVR,          /p\         P                  ! R4      pV  F  pW5,          p\         P                  ! VVR,          VR,          V\         P
                  ! V^,          4      ,          .4      p\        RWV4      p\        W4       V) ^ 8  P                  \        4      ^,          ^,
          p	\        RV) WE4      p\        WV,          4       K  	  \         P                  ! . R	O4      p\         P                  ! V^ ,          V^ ,          ,          VR ,          V^,          R,          V^,          \         P
                  ! V^,          4      ,          .4      p\        WaVR 4      p\        W4       V) ^ 8  P                  \        4      ^,          ^,
          p	\        Wa) VR 4      p\        WV,          4       R# )
r*   r,   r-   r+   r   Nr/   )r
  r   r   g     j@r.   )rP   r   
   d   )
r   r   r0   r1   r2   rS   r   r   rD  float)
methodsrF   r5   r6   r  r7   r  correct_stepr   sign_x0s
             r&   test__compute_absolute_stepr  M  s   *G	#	$B
((2::

"
"C383:c3hM
 
#B (xx!)B!)B!)BFF2a5M!9!; <
 *$?/3!8##E*Q.2)$R@L"89  xx)*H88Xa[2a50*95%a[2-%a[266"Q%=8: ;L
 &hB	BHH+sax&*Q.G%hRCHH45r(   )$r   	itertoolsr   numpyr   numpy.testingr   r   r   rl  r   r  scipy._lib._utilr   r	   scipy.sparser
   r   r   scipy.optimize._numdiffr   r   r   r   r   r   scipy.optimizer   r'   r8   r:   rg   rp  r  r  r  r]   r(   r&   <module>r     s|       @ @  * ? 8 8< < !%8!
HG9 G9T[! [!|\! \!~|< |<~2'j(6r(   