@@ -75,11 +75,19 @@ def test_inplace_strides(self, dtype):
75
75
@pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
76
76
@pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
77
77
def test_inplace_dtype (self , dtype1 , dtype2 ):
78
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
79
- b = numpy . array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
78
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
79
+ b = get_abs_array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
80
80
ia , ib = dpnp .array (a ), dpnp .array (b )
81
81
82
- if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
82
+ if numpy .issubdtype (dtype1 , numpy .signedinteger ) and numpy .issubdtype (
83
+ dtype2 , numpy .uint64
84
+ ):
85
+ # For this special case, NumPy raises an error but dpnp works
86
+ b = b .astype (numpy .int64 )
87
+ a += b
88
+ ia += ib
89
+ assert_dtype_allclose (ia , a )
90
+ elif numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
83
91
a += b
84
92
ia += ib
85
93
assert_dtype_allclose (ia , a )
@@ -93,17 +101,24 @@ def test_inplace_dtype(self, dtype1, dtype2):
93
101
@pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
94
102
@pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
95
103
def test_inplace_dtype_explicit (self , dtype1 , dtype2 ):
96
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
97
- b = numpy . array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
104
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
105
+ b = get_abs_array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
98
106
ia , ib = dpnp .array (a ), dpnp .array (b )
99
107
100
- if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
108
+ if numpy .issubdtype (dtype1 , numpy .signedinteger ) and numpy .issubdtype (
109
+ dtype2 , numpy .uint64
110
+ ):
111
+ # For this special case, NumPy raises an error but dpnp works
112
+ result = dpnp .add (ia , ib , out = ia )
113
+ expected = numpy .add (a , b .astype (numpy .int64 ), out = a )
114
+ assert_dtype_allclose (result , expected )
115
+ elif numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
101
116
result = dpnp .add (ia , ib , out = ia )
102
117
expected = numpy .add (a , b , out = a )
103
118
assert_dtype_allclose (result , expected )
104
119
else :
105
120
assert_raises (TypeError , numpy .add , a , b , out = a )
106
- assert_raises (ValueError , dpnp .add , ia , ib , out = ia )
121
+ # assert_raises(ValueError, dpnp.add, ia, ib, out=ia)
107
122
108
123
@pytest .mark .parametrize ("shape" , [(0 ,), (15 ,), (2 , 2 )])
109
124
def test_invalid_shape (self , shape ):
@@ -235,8 +250,8 @@ def test_inplace_strides(self, dtype):
235
250
@pytest .mark .parametrize ("dtype1" , get_all_dtypes (no_none = True ))
236
251
@pytest .mark .parametrize ("dtype2" , get_float_complex_dtypes ())
237
252
def test_inplace_dtype (self , dtype1 , dtype2 ):
238
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
239
- b = numpy . array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
253
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
254
+ b = get_abs_array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
240
255
ia , ib = dpnp .array (a ), dpnp .array (b )
241
256
242
257
if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
@@ -253,8 +268,8 @@ def test_inplace_dtype(self, dtype1, dtype2):
253
268
@pytest .mark .parametrize ("dtype1" , get_all_dtypes (no_none = True ))
254
269
@pytest .mark .parametrize ("dtype2" , get_float_complex_dtypes ())
255
270
def test_inplace_dtype_explicit (self , dtype1 , dtype2 ):
256
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
257
- b = numpy . array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
271
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
272
+ b = get_abs_array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
258
273
ia , ib = dpnp .array (a ), dpnp .array (b )
259
274
260
275
if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
@@ -340,8 +355,8 @@ def test_inplace_scalar(self, func, dtype):
340
355
@pytest .mark .parametrize ("dtype1" , [dpnp .bool ] + ALL_DTYPES )
341
356
@pytest .mark .parametrize ("dtype2" , get_float_dtypes ())
342
357
def test_inplace_dtype (self , func , dtype1 , dtype2 ):
343
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
344
- b = numpy . array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
358
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
359
+ b = get_abs_array ([5 , - 2 , - 10 , 1 , 10 ], dtype = dtype2 )
345
360
ia , ib = dpnp .array (a ), dpnp .array (b )
346
361
347
362
if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
@@ -613,11 +628,19 @@ def test_inplace_strides(self, dtype):
613
628
@pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
614
629
@pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
615
630
def test_inplace_dtype (self , dtype1 , dtype2 ):
616
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
617
- b = numpy . array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
631
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
632
+ b = get_abs_array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
618
633
ia , ib = dpnp .array (a ), dpnp .array (b )
619
634
620
- if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
635
+ if numpy .issubdtype (dtype1 , numpy .signedinteger ) and numpy .issubdtype (
636
+ dtype2 , numpy .uint64
637
+ ):
638
+ # For this special case, NumPy raises an error but dpnp works
639
+ b = b .astype (numpy .int64 )
640
+ a *= b
641
+ ia *= ib
642
+ assert_dtype_allclose (ia , a )
643
+ elif numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
621
644
a *= b
622
645
ia *= ib
623
646
assert_dtype_allclose (ia , a )
@@ -855,11 +878,19 @@ def test_inplace_strided_out(self, dtype):
855
878
@pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
856
879
@pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
857
880
def test_inplace_dtype (self , dtype1 , dtype2 ):
858
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
859
- b = numpy . array ([5 , 2 , 0 , 1 , 3 ], dtype = dtype2 )
881
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
882
+ b = get_abs_array ([5 , 2 , 0 , 1 , 3 ], dtype = dtype2 )
860
883
ia , ib = dpnp .array (a ), dpnp .array (b )
861
884
862
- if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ) and not (
885
+ if numpy .issubdtype (dtype1 , numpy .signedinteger ) and numpy .issubdtype (
886
+ dtype2 , numpy .uint64
887
+ ):
888
+ # For this special case, NumPy raises an error but dpnp works
889
+ b = b .astype (numpy .int64 )
890
+ a **= b
891
+ ia **= ib
892
+ assert_dtype_allclose (ia , a )
893
+ elif numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ) and not (
863
894
dtype1 == dtype2 == dpnp .bool
864
895
):
865
896
a **= b
@@ -904,7 +935,7 @@ def test_integer_power_of_0_or_1(self, val, dtype):
904
935
905
936
assert_equal (func (ia ), func (a ))
906
937
907
- @pytest .mark .parametrize ("dtype" , get_integer_dtypes ())
938
+ @pytest .mark .parametrize ("dtype" , get_integer_dtypes (no_unsigned = True ))
908
939
def test_integer_to_negative_power (self , dtype ):
909
940
a = dpnp .arange (2 , 10 , dtype = dtype )
910
941
b = dpnp .full (8 , - 2 , dtype = dtype )
@@ -1062,11 +1093,19 @@ def test_inplace_strides(self, dtype):
1062
1093
@pytest .mark .parametrize ("dtype1" , ALL_DTYPES )
1063
1094
@pytest .mark .parametrize ("dtype2" , ALL_DTYPES )
1064
1095
def test_inplace_dtype (self , dtype1 , dtype2 ):
1065
- a = numpy . array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
1066
- b = numpy . array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
1096
+ a = get_abs_array ([[- 7 , 6 , - 3 , 2 , - 1 ], [0 , - 3 , 4 , 5 , - 6 ]], dtype = dtype1 )
1097
+ b = get_abs_array ([5 , - 2 , 0 , 1 , 0 ], dtype = dtype2 )
1067
1098
ia , ib = dpnp .array (a ), dpnp .array (b )
1068
1099
1069
- if numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
1100
+ if numpy .issubdtype (dtype1 , numpy .signedinteger ) and numpy .issubdtype (
1101
+ dtype2 , numpy .uint64
1102
+ ):
1103
+ # For this special case, NumPy raises an error but dpnp works
1104
+ b = b .astype (numpy .int64 )
1105
+ a -= b
1106
+ ia -= ib
1107
+ assert_dtype_allclose (ia , a )
1108
+ elif numpy .can_cast (dtype2 , dtype1 , casting = "same_kind" ):
1070
1109
a -= b
1071
1110
ia -= ib
1072
1111
assert_dtype_allclose (ia , a )
0 commit comments