@@ -216,7 +216,7 @@ def test_arange(start, stop, step, dtype):
216
216
func = lambda xp : xp .arange (start , stop = stop , step = step , dtype = dtype )
217
217
218
218
exp_array = func (numpy )
219
- res_array = func (dpnp ). asnumpy ()
219
+ res_array = func (dpnp )
220
220
221
221
if dtype is None :
222
222
_device = dpctl .SyclQueue ().sycl_device
@@ -234,7 +234,7 @@ def test_arange(start, stop, step, dtype):
234
234
_dtype , dpnp .complexfloating
235
235
):
236
236
assert_allclose (
237
- exp_array , res_array , rtol = rtol_mult * numpy .finfo (_dtype ).eps
237
+ res_array , exp_array , rtol = rtol_mult * numpy .finfo (_dtype ).eps
238
238
)
239
239
else :
240
240
assert_array_equal (exp_array , res_array )
@@ -540,7 +540,7 @@ def test_vander(array, dtype, n, increase):
540
540
a_np = numpy .array (array , dtype = dtype )
541
541
a_dpnp = dpnp .array (array , dtype = dtype )
542
542
543
- assert_allclose (vander_func (numpy , a_np ), vander_func (dpnp , a_dpnp ))
543
+ assert_allclose (vander_func (dpnp , a_dpnp ), vander_func (numpy , a_np ))
544
544
545
545
546
546
def test_vander_raise_error ():
@@ -560,7 +560,7 @@ def test_vander_raise_error():
560
560
)
561
561
def test_vander_seq (sequence ):
562
562
vander_func = lambda xp , x : xp .vander (x )
563
- assert_allclose (vander_func (numpy , sequence ), vander_func (dpnp , sequence ))
563
+ assert_allclose (vander_func (dpnp , sequence ), vander_func (numpy , sequence ))
564
564
565
565
566
566
@pytest .mark .usefixtures ("suppress_complex_warning" )
@@ -607,19 +607,19 @@ def test_full_order(order1, order2):
607
607
608
608
assert ia .flags .c_contiguous == a .flags .c_contiguous
609
609
assert ia .flags .f_contiguous == a .flags .f_contiguous
610
- assert numpy . array_equal ( dpnp . asnumpy ( ia ) , a )
610
+ assert_equal ( ia , a )
611
611
612
612
613
613
def test_full_strides ():
614
614
a = numpy .full ((3 , 3 ), numpy .arange (3 , dtype = "i4" ))
615
615
ia = dpnp .full ((3 , 3 ), dpnp .arange (3 , dtype = "i4" ))
616
616
assert ia .strides == tuple (el // a .itemsize for el in a .strides )
617
- assert_array_equal (dpnp . asnumpy ( ia ) , a )
617
+ assert_array_equal (ia , a )
618
618
619
619
a = numpy .full ((3 , 3 ), numpy .arange (6 , dtype = "i4" )[::2 ])
620
620
ia = dpnp .full ((3 , 3 ), dpnp .arange (6 , dtype = "i4" )[::2 ])
621
621
assert ia .strides == tuple (el // a .itemsize for el in a .strides )
622
- assert_array_equal (dpnp . asnumpy ( ia ) , a )
622
+ assert_array_equal (ia , a )
623
623
624
624
625
625
@pytest .mark .parametrize (
@@ -762,20 +762,12 @@ def test_linspace(start, stop, num, dtype, retstep):
762
762
assert_dtype_allclose (res_dp , res_np )
763
763
764
764
765
+ @pytest .mark .parametrize ("func" , ["geomspace" , "linspace" , "logspace" ])
765
766
@pytest .mark .parametrize (
766
- "func" ,
767
- ["geomspace" , "linspace" , "logspace" ],
768
- ids = ["geomspace" , "linspace" , "logspace" ],
767
+ "start_dtype" , [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ]
769
768
)
770
769
@pytest .mark .parametrize (
771
- "start_dtype" ,
772
- [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ],
773
- ids = ["float64" , "float32" , "int64" , "int32" ],
774
- )
775
- @pytest .mark .parametrize (
776
- "stop_dtype" ,
777
- [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ],
778
- ids = ["float64" , "float32" , "int64" , "int32" ],
770
+ "stop_dtype" , [numpy .float64 , numpy .float32 , numpy .int64 , numpy .int32 ]
779
771
)
780
772
def test_space_numpy_dtype (func , start_dtype , stop_dtype ):
781
773
start = numpy .array ([1 , 2 , 3 ], dtype = start_dtype )
@@ -890,10 +882,7 @@ def test_geomspace(sign, dtype, num, endpoint):
890
882
np_res = func (numpy )
891
883
dpnp_res = func (dpnp )
892
884
893
- if dtype in [numpy .int64 , numpy .int32 ]:
894
- assert_allclose (dpnp_res , np_res , rtol = 1 )
895
- else :
896
- assert_allclose (dpnp_res , np_res , rtol = 1e-04 )
885
+ assert_allclose (dpnp_res , np_res , rtol = 1e-06 )
897
886
898
887
899
888
@pytest .mark .parametrize ("start" , [1j , 1 + 1j ])
@@ -902,22 +891,22 @@ def test_geomspace_complex(start, stop):
902
891
func = lambda xp : xp .geomspace (start , stop , num = 10 )
903
892
np_res = func (numpy )
904
893
dpnp_res = func (dpnp )
905
- assert_allclose (dpnp_res , np_res , rtol = 1e-04 )
894
+ assert_allclose (dpnp_res , np_res , rtol = 1e-06 )
906
895
907
896
908
897
@pytest .mark .parametrize ("axis" , [0 , 1 ])
909
898
def test_geomspace_axis (axis ):
910
899
func = lambda xp : xp .geomspace ([2 , 3 ], [20 , 15 ], num = 10 , axis = axis )
911
900
np_res = func (numpy )
912
901
dpnp_res = func (dpnp )
913
- assert_allclose (dpnp_res , np_res , rtol = 1e-04 )
902
+ assert_allclose (dpnp_res , np_res , rtol = 1e-06 )
914
903
915
904
916
905
def test_geomspace_num0 ():
917
906
func = lambda xp : xp .geomspace (1 , 10 , num = 0 , endpoint = False )
918
907
np_res = func (numpy )
919
908
dpnp_res = func (dpnp )
920
- assert_allclose (dpnp_res , np_res , rtol = 1e-04 )
909
+ assert_allclose (dpnp_res , np_res )
921
910
922
911
923
912
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
@@ -935,10 +924,7 @@ def test_logspace(dtype, num, endpoint):
935
924
np_res = func (numpy )
936
925
dpnp_res = func (dpnp )
937
926
938
- if dtype in [numpy .int64 , numpy .int32 ]:
939
- assert_allclose (dpnp_res , np_res , rtol = 1 )
940
- else :
941
- assert_allclose (dpnp_res , np_res , rtol = 1e-04 )
927
+ assert_allclose (dpnp_res , np_res , rtol = 1e-06 )
942
928
943
929
944
930
@pytest .mark .parametrize ("axis" , [0 , 1 ])
0 commit comments