
    biH                     X    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Z	 G d d      Z
y)    N)assert_allclose)geometric_slerpc                 
   t         j                  j                  d       t         j                  j                  || f      }|t         j                  j                  |d      d d t         j                  f   z  }|d   |d   fS )N{   )size   axisr   )nprandomseednormallinalgnormnewaxis)ndimn_ptspointss      Y/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/scipy/spatial/tests/test_slerp.py_generate_spherical_pointsr      sj    
 IINN3YYE4=1F
biinnV!n,Q

];;F!9fQi    c                      e Zd Zej                  j                  dg d      ej                  j                  dg d      d               Zej                  j                  dg d      ej                  j                  dddg      d               Zej                  j                  d	 ej                  d
       ej                  d
      f ej                  d
       ej                  d      f ej                  d       ej                  d      fg      d        Zej                  j                  d	 ej                  d       ej                  d      f ej                  d       ej                  d      f ej                  g        ej                  d      fg      d        Zej                  j                  d	 ej                  g        ej                  g       fg      d        Zej                  j                  d ej                  g d       ej                  g d      df ej                  g d       ej                  g d      df ej                  g d       ej                  g d      dfg      d        Zej                  j                  d ej                  ddg       ej                  ddg       ej                  ddg ej                   d      dz  dgd ej                   d      dz  gddgg      f ej                  g d       ej                  g d       ej                  g d ej                   d      dz  ddgd ej                   d      dz  dgg dg      f ej                  g d       ej                  g d       ej                  g d ej                   d      dz  ddddgd ej                   d      dz  dddgg dg      fg      d         Zej                  j                  d	 ej                  dg       ej                  dg      f ej                  dg       ej                  dg      f ej                  d!g       ej                  d"g      fg      d#        Zej                  j                  d$d%d&g d' ej                  d(      g      d)        Zej                  j                  d$d*d+g      d,        Zej                  j                  d	 ej                  ddg       ej                  ddg      f ej                  g d-       ej                  g d.      f ej                  g d/       ej                  g d0      fg      d1        Zej                  j                  d	 ej                  ddg       ej                   ej                   d      d2z   ej                   d      d2z  g      f ej                  ddg       ej                   ej                   d       d2z   ej                   d      d2z  g      fg      ej                  j                  d3ej,                  ej.                  g      d4               Zej                  j                  d5d6g      d7        Zd8 Zd9 Zej                  j                  d: ej                  g d       ej                  ddg      g      ej                  j                  d5 ej                  d       ej                  dg       ej                  dgg       ej                  dggg       ej                  g        ej,                  ddd%      g      d;               Zej                  j                  d< ej.                  d=d>d?            d@        Zej                  j                  d5ddggddgggggggggg      dA        Zej                  j                  dBddgddgddd>gfddg ej                   d      dz   ej                   d      dz  gdCdd>gfddg ej                   d      dz   ej                   d      dz  gdDd>dgfddg ej                   d      dz   ej                   d      dz  gd ej                   d       dz   ej                   d      dz  gfddg ej                   d      dz   ej                   d      dz  gg dE ej                   d       dz   ej                   d      dz  gd>dgdd>ggfg d ej                   d      dz   ej                   d      dz  dgg dE ej                   d       dz   ej                   d      dz  dgg dFg dGgfddg ej                   d      dz   ej                   d      dz  gdH ej                   d      dz  dgfg      dI        Z ej                  j                  dBg dJg dKdLg dJfg dJg dKd>g dKfg      dM        Z!yN)OTestGeometricSlerpn_dims)            	   r   )r   r      c           	          t        |d      \  }}t        ||t        j                  dd|            }|j                  ||fk(  sJ y )Nr   r   r   startendt)r   r   r   linspaceshapeselfr   r   r#   r$   actuals         r   test_shape_propertyz&TestGeometricSlerp.test_shape_property   sK     0:
s u%(#%;;q!U#;= ||v...r   r   r    c           	          t        |d      \  }}t        ||t        j                  dd|            }t	        |d   |       t	        |d   |       y )Nr   r   r   r"   )r   r   r   r&   r   r(   s         r   test_include_endsz$TestGeometricSlerp.test_include_ends'   sQ     0:
s u%(#%;;q!U#;= 	q	5)r
C(r   z
start, end)r   r   r   )r   r   c           
          t        j                  t        d      5  t        ||t	        j
                  ddd             d d d        y # 1 sw Y   y xY w)Nzone-dimensionalmatchr   r   
   r"   pytestraises
ValueErrorr   r   r&   r)   r#   r$   s      r   test_input_shape_flatz(TestGeometricSlerp.test_input_shape_flat<   sE     ]]:->? 	5% # kk!Q35	5 	5 	5   $A		Ar   r   c           
          t        j                  t        d      5  t        ||t	        j
                  ddd             d d d        y # 1 sw Y   y xY w)N
dimensionsr0   r   r   r2   r"   r3   r7   s      r   test_input_dim_mismatchz*TestGeometricSlerp.test_input_dim_mismatchL   sD     ]]:\: 	5% # kk!Q35	5 	5 	5r9   c           
          t        j                  t        d      5  t        ||t	        j
                  ddd             d d d        y # 1 sw Y   y xY w)Nat least two-dimr0   r   r   r2   r"   r3   r7   s      r   test_input_at_least1dz(TestGeometricSlerp.test_input_at_least1d]   sE     ]]:-?@ 	5% # kk!Q35	5 	5 	5r9   zstart, end, expected)r   r         ?)r   r   g      warning)        gԬ3ODgkꚛ?)rB   g{tOgx?successc           
      R   |dk(  rHt        j                  t        d      5  t        ||t	        j
                  ddd            }d d d        n#t        ||t	        j
                  ddd            }t        t        j                  j                  d      d	       y # 1 sw Y   5xY w)
NrA   	antipodesr0   r   r   r2   r"   r	   r@   )	r4   warnsUserWarningr   r   r&   r   r   r   )r)   r#   r$   expectedress        r   test_handle_antipodesz(TestGeometricSlerp.test_handle_antipodesj   s    4 y k= ?%E*-(*Aq"(=?? ?
 "&)$&KK1b$9;C 			s3S9? ?s   $BB&r         ?)r   r   r   )r   r   r   )r   r   r   r   r   )r   r   r   r   r   c           	      f    t        ||t        j                  ddd            }t        ||d       y )Nr   r      r"   缉ؗҜ<atol)r   r   r&   r   )r)   r#   r$   rH   r*   s        r   test_straightforward_examplesz0TestGeometricSlerp.test_straightforward_examples   s2    D !u%(#%;;q!Q#79 	u5r   g333331g̼d@c           
          t        j                  t        d      5  t        ||t	        j
                  ddd            }d d d        y # 1 sw Y   y xY w)Nr>   r0   r   r   rM   r"   r3   )r)   r#   r$   _s       r   test_0_sphere_handlingz)TestGeometricSlerp.test_0_sphere_handling   sG     ]]:-?@ 	8e$'"$++aA"68A	8 	8 	8r9   tolr   7)r      r   g      "@c           
          t        j                  t        d      5  t        t	        j
                  ddg      t	        j
                  ddg      t	        j                  ddd      |      }d d d        y # 1 sw Y   y xY w)Nzmust be a floatr0   r   r   r   r#   r$   r%   rU   )r4   r5   r6   r   r   arrayr&   r)   rU   rS   s      r   test_tol_typez TestGeometricSlerp.test_tol_type   sd     ]]:->? 	)bhh1v&6$&HHaV$4"$++aA"6$')A	) 	) 	)s   AA44A=gh㈵ԾgƜCc           	          t        t        j                  ddg      t        j                  ddg      t        j                  ddd      |      }y )Nr   r   r   rY   )r   r   rZ   r&   r[   s      r   test_tol_signz TestGeometricSlerp.test_tol_sign   s@     "((Aq6"2 "!Q 0 kk!Q2 #%r   )zo ?r   r   )r   !?r   )r_   r   r   r   )r   r`   r   r   c           
          t        j                  t        d      5  t        ||t	        j
                  ddd             d d d        y # 1 sw Y   y xY w)Nzunit n-spherer0   r   r   r   r"   r3   r7   s      r   test_unit_sphere_enforcementz/TestGeometricSlerp.test_unit_sphere_enforcement   sD      ]]:_= 	4% # kk!Q24	4 	4 	4r9   g       @t_funcc                    d}t         j                  j                  d        |dd|      }||j                         z  }t        j                  |      }t        j
                  |      }t         j                  j                  |       |j                         |   }t        |||      }	t        |||      }
t        |||      }t        |	t        j                  |
             t        |	|   |       y )N   i  r   r2   r"   )
r   r   r   maxflipudarangeshufflecopyr   r   )r)   r#   r$   rc   
num_t_valsforward_t_valsreverse_t_valsshuffled_indicesscramble_t_valsforward_resultsreverse_resultsscrambled_resultss               r   test_order_handlingz&TestGeometricSlerp.test_order_handling   s    ( 

		s2z2.,,..>299Z0
		*+(--/0@A).1,:< *.1,:< ,%03.=?
 	?)CD(89)	+r   r%   z15, 5, 7c                     t        j                  t              5  t        t	        j
                  dg      t	        j
                  dg      |      }d d d        y # 1 sw Y   y xY w)Nr   r   r"   )r4   r5   r6   r   r   rZ   )r)   r%   rS   s      r   test_t_values_conversionz+TestGeometricSlerp.test_t_values_conversion)  sK     ]]:& 	%bhhsm$&HHaSM"#%A	% 	% 	%s   7AA#c           	      ^   t        ddgddgg d      }t        j                  ddgt        j                  d      dz  dgt        j                  d      dz  t        j                  d      dz  gdt        j                  d      dz  gddggt        j                        }t        ||d	       y )
Nr   r   )r   gUUUUUU?rK   gUUUUUU?r   r   r   rK   dtyperN   rO   )r   r   rZ   sqrtfloat64r   r)   r*   rH   s      r   test_accept_arraylikez(TestGeometricSlerp.test_accept_arraylike6  s     !!Q!Q1FG
 88aV ggaj1nc2 ggaj1n ggaj1n.!2771:>2V%
 -/JJ8 	u5r   c                    t        ddgddgd      }t        j                  t        j                  d      dz  t        j                  d      dz  gt        j                        }|j
                  dk(  sJ t        ||       y )Nr   r   rK   r   rw   )r   )r   r   rZ   ry   rz   r'   r   r{   s      r   test_scalar_tz TestGeometricSlerp.test_scalar_tJ  sn     !!Q!Q588RWWQZ!^WWQZ!^-46JJ@||t###)r   r#   c                    t        j                  |      j                  dkD  r1t        j                  t
              5  t        |||       d d d        y |j                  f|j                  z   }t        j                  ||      }t        |||      }t        ||       t        ||d d d   |      }|j                  |j                  k(  sJ y # 1 sw Y   y xY w)Nr   r"   r-   )r   asarrayr   r4   r5   r6   r   r   r'   fullr   )r)   r#   r%   r'   rH   r*   non_degenerates          r   test_degenerate_inputz(TestGeometricSlerp.test_degenerate_inputT  s     ::a=!z* =e!<= = VVI+Ewwue,H$5eqAFFH- -5eDbDkQON;;."5"5555= =s   CCkir-   r2   c                 N   t         j                  |z
  }t        j                  ddd      }t        j                  g d      }t        j                  t        j                  |      t        j
                  |      ddg      }t        j                         5  t        j                  dt               t        |||d      }t         j                  j                  |d      }t        j                  t        j                  |dz
              }|dk  sJ 	 d d d        y # 1 sw Y   y xY w)	Nr   r   d   )r   r   r   r   ignoregC]r2<r	   gV瞯<)r   pir&   rZ   cossinwarningscatch_warningssimplefilterrG   r   r   r   rf   abs)	r)   r   angletsPQresultnormserrors	            r   test_numerical_stability_piz.TestGeometricSlerp.test_numerical_stability_piq  s    
 	[[As#HH\"HHbffUmRVVE]Aq9: $$& 	!!!(K8$Q2u5FIINN6N2EFF266%!),-E5= =	! 	! 	!s   A<DD$c                 P   t        j                  ddg      }t        j                  ddg      }t        j                  t              5  t        |||       d d d        t        j                  t              5  t        |||       d d d        y # 1 sw Y   :xY w# 1 sw Y   y xY w)Nr   r   r"   )r   rZ   r4   r5   r6   r   )r)   r%   arr1arr2s       r   test_interpolation_param_ndimz0TestGeometricSlerp.test_interpolation_param_ndim  s     xxAxxA]]:& 	!$ $!	!
 ]]:& 	!$ $!	! 	!	! 	!
	! 	!s   B8BBB%zstart, end, t, expectedrM   rW   )r   rW   rM   )r-   r   r   )r   r-   r   gc                 <    t        |||      }t        ||d       y )Nr"   gؗҬ<rO   )r   r   r)   r#   r$   r%   rH   actual_paths         r   test_extrapolation_basicz+TestGeometricSlerp.test_extrapolation_basic  s%    H &E*-()+ 	XE:r   )r   r   r   )r   r   r-   c                     t        j                  t        d      5  t        |||      }d d d        t	        |d       y # 1 sw Y   xY w)NrE   r0   r"   g}-<rO   )r4   rF   rG   r   r   r   s         r   test_extrapolation_antipodesz/TestGeometricSlerp.test_extrapolation_antipodes  sE     \\+[9 	E)3!DK	EXG<	E 	Es   AAN)"__name__
__module____qualname__r4   markparametrizer+   r.   r   zerosonesr8   rZ   r<   r?   rJ   ry   rQ   rT   r\   r^   rb   r&   logspacers   ru   r|   r~   r   r   r   mathr   r    r   r   r   r      sm
    [[X7[[Wj1
/ 2 8
/ [[X7[[Wq"g.) / 8)& [[\	&	72776?+	&	72771:&	!gbggfo&,
 55 [[\	!gbggaj!	!gbggaj!	"wrwwqz",
 55 [[\	"xrxx|$,
 5	5 [[3 
+	 6	B 
 " 
#$,BHH\$:I	G 
 " 
#$,BHH\$:I	G%6
 ,:-,:& [[3 
1a&		1a&		Aq6BGGAJNC(a(q6 
	 
)		)		9BGGAJNC+a+ 
	  
/	"	/	"	?BGGAJNCAq1aAq1"$ 
%	&+6 :6;:6 [[\	1#	1#		1#	1#		5'		5'		, 88 [[U	8288C=%
 )) [[U%
 %	% [[\ 
1a&	8288QF+, 
"	#	"	#	% 
%	&	%	&	(,
 44 [[\	1a&		72771:?2771:?$ 
%	& 
1a&		GBGGAJ;#2771:?$ 
%	&	,
 	 [[X
R[[(" #+#	+B [[S#
 %%6(* [[W!Q'  [[S!1#A3%Aq!# 6	6" [[S+"++c2r":;! <!$ [[S#hZXJ<.	# !	!  [[6 Q!QQG$ Q)$))A,q.)$))A,q.11q"g>
Q)$))A,q.)$))A,q.11r1g>
Q)$))A,q.)$))A,q.11499Q<-/9499Q<>	*	, Q
$))A,q.)$))A,q.	)	DIIaL=?IDIIaLN
+q'b'
	 

$))A,q.)$))A,q.!	,	DIIaL=?IDIIaLNA
.


	 Q)$))A,q.)$))A,q.1Gytyy|A~s>STC"9 "F;G"F; [[6 
B	* 
B
+9 ==r   r   )r   r   )r   r   numpyr   numpy.testingr   r4   scipy.spatialr   r   r   r   r   r   <module>r      s(       )  ) {= {=r   