2323class TestAsType :
2424 @pytest .mark .usefixtures ("suppress_complex_warning" )
2525 @pytest .mark .parametrize ("res_dtype" , get_all_dtypes ())
26- @pytest .mark .parametrize ("arr_dtype" , get_all_dtypes ())
26+ @pytest .mark .parametrize ("arr_dtype" , get_all_dtypes (no_none = True ))
2727 @pytest .mark .parametrize (
2828 "arr" ,
2929 [[- 2 , - 1 , 0 , 1 , 2 ], [[- 2 , - 1 ], [1 , 2 ]], []],
@@ -35,7 +35,7 @@ def test_basic(self, arr, arr_dtype, res_dtype):
3535
3636 expected = a .astype (res_dtype )
3737 result = ia .astype (res_dtype )
38- assert_allclose (expected , result )
38+ assert_allclose (result , expected )
3939
4040 def test_subok_error (self ):
4141 x = dpnp .ones (4 )
@@ -88,18 +88,18 @@ def test_create_from_usm_ndarray_error(arr):
8888 dpnp .ndarray ._create_from_usm_ndarray (arr )
8989
9090
91- @pytest .mark .parametrize ("arr_dtype" , get_all_dtypes ())
91+ @pytest .mark .parametrize ("arr_dtype" , get_all_dtypes (no_none = True ))
9292@pytest .mark .parametrize (
9393 "arr" ,
9494 [[- 2 , - 1 , 0 , 1 , 2 ], [[- 2 , - 1 ], [1 , 2 ]], []],
9595 ids = ["[-2, -1, 0, 1, 2]" , "[[-2, -1], [1, 2]]" , "[]" ],
9696)
9797def test_flatten (arr , arr_dtype ):
98- numpy_array = get_abs_array (arr , arr_dtype )
99- dpnp_array = dpnp .array (numpy_array )
100- expected = numpy_array .flatten ()
101- result = dpnp_array .flatten ()
102- assert_array_equal (expected , result )
98+ a = get_abs_array (arr , arr_dtype )
99+ ia = dpnp .array (a )
100+ expected = a .flatten ()
101+ result = ia .flatten ()
102+ assert_array_equal (result , expected )
103103
104104
105105@pytest .mark .parametrize (
@@ -110,17 +110,16 @@ def test_flatten(arr, arr_dtype):
110110@pytest .mark .parametrize ("order" , ["C" , "F" ])
111111def test_flags (shape , order ):
112112 usm_array = dpt .usm_ndarray (shape , order = order )
113- numpy_array = numpy .ndarray (shape , order = order )
114- dpnp_array = dpnp .ndarray (shape , order = order )
115- assert usm_array .flags == dpnp_array .flags
116- assert numpy_array .flags .c_contiguous == dpnp_array .flags .c_contiguous
117- assert numpy_array .flags .f_contiguous == dpnp_array .flags .f_contiguous
113+ a = numpy .ndarray (shape , order = order )
114+ ia = dpnp .ndarray (shape , order = order )
115+ assert usm_array .flags == ia .flags
116+ assert a .flags .c_contiguous == ia .flags .c_contiguous
117+ assert a .flags .f_contiguous == ia .flags .f_contiguous
118118
119119
120120@pytest .mark .parametrize (
121121 "dtype" ,
122122 [numpy .complex64 , numpy .float32 , numpy .int64 , numpy .int32 , numpy .bool_ ],
123- ids = ["complex64" , "float32" , "int64" , "int32" , "bool" ],
124123)
125124@pytest .mark .parametrize ("strides" , [(1 , 4 ), (4 , 1 )], ids = ["(1, 4)" , "(4, 1)" ])
126125@pytest .mark .parametrize ("order" , ["C" , "F" ])
@@ -130,13 +129,11 @@ def test_flags_strides(dtype, order, strides):
130129 usm_array = dpt .usm_ndarray (
131130 (4 , 4 ), dtype = dtype , order = order , strides = strides
132131 )
133- numpy_array = numpy .ndarray (
134- (4 , 4 ), dtype = dtype , order = order , strides = numpy_strides
135- )
136- dpnp_array = dpnp .ndarray ((4 , 4 ), dtype = dtype , order = order , strides = strides )
137- assert usm_array .flags == dpnp_array .flags
138- assert numpy_array .flags .c_contiguous == dpnp_array .flags .c_contiguous
139- assert numpy_array .flags .f_contiguous == dpnp_array .flags .f_contiguous
132+ a = numpy .ndarray ((4 , 4 ), dtype = dtype , order = order , strides = numpy_strides )
133+ ia = dpnp .ndarray ((4 , 4 ), dtype = dtype , order = order , strides = strides )
134+ assert usm_array .flags == ia .flags
135+ assert a .flags .c_contiguous == ia .flags .c_contiguous
136+ assert a .flags .f_contiguous == ia .flags .f_contiguous
140137
141138
142139def test_flags_writable ():
@@ -383,9 +380,9 @@ def test_print_dpnp_zero_shape():
383380 "dtype" , get_all_dtypes (no_float16 = False , no_complex = True )
384381)
385382def test_scalar_type_casting (func , shape , dtype ):
386- numpy_array = numpy .full (shape , 5 , dtype = dtype )
387- dpnp_array = dpnp .full (shape , 5 , dtype = dtype )
388- assert func (numpy_array ) == func (dpnp_array )
383+ a = numpy .full (shape , 5 , dtype = dtype )
384+ ia = dpnp .full (shape , 5 , dtype = dtype )
385+ assert func (a ) == func (ia )
389386
390387
391388# Numpy will raise an error when converting a.ndim > 0 to a scalar
@@ -396,12 +393,12 @@ def test_scalar_type_casting(func, shape, dtype):
396393)
397394@pytest .mark .parametrize ("shape" , [tuple (), (1 ,), (1 , 1 ), (1 , 1 , 1 )])
398395@pytest .mark .parametrize (
399- "dtype" , get_all_dtypes (no_float16 = False , no_complex = True , no_none = True )
396+ "dtype" , get_all_dtypes (no_float16 = False , no_complex = True )
400397)
401398def test_scalar_type_casting_by_method (method , shape , dtype ):
402- numpy_array = numpy .full (shape , 4.7 , dtype = dtype )
403- dpnp_array = dpnp .full (shape , 4.7 , dtype = dtype )
404- assert getattr (numpy_array , method )() == getattr (dpnp_array , method )()
399+ a = numpy .full (shape , 4.7 , dtype = dtype )
400+ ia = dpnp .full (shape , 4.7 , dtype = dtype )
401+ assert_allclose ( getattr (a , method )(), getattr (ia , method )(), rtol = 1e-06 )
405402
406403
407404@pytest .mark .parametrize ("shape" , [(1 ,), (1 , 1 ), (1 , 1 , 1 )])
@@ -452,18 +449,18 @@ def test_ravel():
452449
453450
454451def test_repeat ():
455- numpy_array = numpy .arange (4 ).repeat (3 )
456- dpnp_array = dpnp .arange (4 ).repeat (3 )
457- assert_array_equal (numpy_array , dpnp_array )
452+ a = numpy .arange (4 ).repeat (3 )
453+ ia = dpnp .arange (4 ).repeat (3 )
454+ assert_array_equal (a , ia )
458455
459456
460457def test_clip ():
461- numpy_array = numpy .arange (10 )
462- dpnp_array = dpnp .arange (10 )
463- result = dpnp .clip (dpnp_array , 3 , 7 )
464- expected = numpy .clip (numpy_array , 3 , 7 )
458+ a = numpy .arange (10 )
459+ ia = dpnp .arange (10 )
460+ result = dpnp .clip (ia , 3 , 7 )
461+ expected = numpy .clip (a , 3 , 7 )
465462
466- assert_array_equal (expected , result )
463+ assert_array_equal (result , expected )
467464
468465
469466def test_rmatmul_dpnp_array ():
0 commit comments