@@ -142,12 +142,14 @@ def absolute(x1, **kwargs):
142
142
143
143
"""
144
144
145
- is_input_dparray = isinstance (x1 , dparray )
146
-
147
- if not use_origin_backend (x1 ) and is_input_dparray and x1 .ndim != 0 and not kwargs :
148
- result = dpnp_absolute (x1 )
145
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
146
+ if x1_desc and not kwargs :
147
+ if not x1_desc .ndim :
148
+ pass
149
+ else :
150
+ result = dpnp_absolute (x1_desc )
149
151
150
- return result
152
+ return result
151
153
152
154
return call_origin (numpy .absolute , x1 , ** kwargs )
153
155
@@ -236,15 +238,14 @@ def around(x1, decimals=0, out=None):
236
238
237
239
"""
238
240
239
- if not use_origin_backend (x1 ):
240
- if not isinstance (x1 , dparray ):
241
- pass
242
- elif out is not None :
241
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
242
+ if x1_desc :
243
+ if out is not None :
243
244
pass
244
245
elif decimals != 0 :
245
246
pass
246
247
else :
247
- return dpnp_around (x1 , decimals )
248
+ return dpnp_around (x1_desc , decimals )
248
249
249
250
return call_origin (numpy .around , x1 , decimals = decimals , out = out )
250
251
@@ -483,7 +484,7 @@ def cumsum(x1, **kwargs):
483
484
return call_origin (numpy .cumsum , x1 , ** kwargs )
484
485
485
486
486
- def diff (input , n = 1 , axis = - 1 , prepend = None , append = None ):
487
+ def diff (x1 , n = 1 , axis = - 1 , prepend = None , append = None ):
487
488
"""
488
489
Calculate the n-th discrete difference along the given axis.
489
490
@@ -496,10 +497,9 @@ def diff(input, n=1, axis=-1, prepend=None, append=None):
496
497
Otherwise the function will be executed sequentially on CPU.
497
498
"""
498
499
499
- if not use_origin_backend (input ):
500
- if not isinstance (input , dparray ):
501
- pass
502
- elif not isinstance (n , int ):
500
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
501
+ if x1_desc :
502
+ if not isinstance (n , int ):
503
503
pass
504
504
elif n < 1 :
505
505
pass
@@ -510,9 +510,9 @@ def diff(input, n=1, axis=-1, prepend=None, append=None):
510
510
elif append is not None :
511
511
pass
512
512
else :
513
- return dpnp_diff (input , n )
513
+ return dpnp_diff (x1 , n )
514
514
515
- return call_origin (numpy .diff , input , n , axis , prepend , append )
515
+ return call_origin (numpy .diff , x1 , n , axis , prepend , append )
516
516
517
517
518
518
def divide (x1 , x2 , dtype = None , out = None , where = True , ** kwargs ):
@@ -848,7 +848,7 @@ def fmod(x1, x2, dtype=None, out=None, where=True, **kwargs):
848
848
return call_origin (numpy .fmod , x1 , x2 , dtype = dtype , out = out , where = where , ** kwargs )
849
849
850
850
851
- def gradient (y1 , * varargs , ** kwargs ):
851
+ def gradient (x1 , * varargs , ** kwargs ):
852
852
"""
853
853
Return the gradient of an array.
854
854
@@ -874,20 +874,20 @@ def gradient(y1, *varargs, **kwargs):
874
874
[0.5, 0.75, 1.25, 1.75, 2.25, 2.5]
875
875
876
876
"""
877
- if not use_origin_backend ( y1 ) and not kwargs :
878
- if not isinstance ( y1 , dparray ):
879
- pass
880
- elif len (varargs ) > 1 :
877
+
878
+ x1_desc = dpnp . get_dpnp_descriptor ( x1 )
879
+ if x1_desc and not kwargs :
880
+ if len (varargs ) > 1 :
881
881
pass
882
882
elif len (varargs ) == 1 and not isinstance (varargs [0 ], int ):
883
883
pass
884
884
else :
885
885
if len (varargs ) == 0 :
886
- return dpnp_gradient (y1 )
886
+ return dpnp_gradient (x1 )
887
887
888
- return dpnp_gradient (y1 , varargs [0 ])
888
+ return dpnp_gradient (x1 , varargs [0 ])
889
889
890
- return call_origin (numpy .gradient , y1 , * varargs , ** kwargs )
890
+ return call_origin (numpy .gradient , x1 , * varargs , ** kwargs )
891
891
892
892
893
893
def maximum (x1 , x2 , dtype = None , out = None , where = True , ** kwargs ):
@@ -1136,11 +1136,9 @@ def nancumprod(x1, **kwargs):
1136
1136
1137
1137
"""
1138
1138
1139
- if not use_origin_backend (x1 ) and not kwargs :
1140
- if not isinstance (x1 , dparray ):
1141
- pass
1142
- else :
1143
- return dpnp_nancumprod (x1 )
1139
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1140
+ if x1_desc and not kwargs :
1141
+ return dpnp_nancumprod (x1_desc )
1144
1142
1145
1143
return call_origin (numpy .nancumprod , x1 , ** kwargs )
1146
1144
@@ -1174,11 +1172,9 @@ def nancumsum(x1, **kwargs):
1174
1172
1175
1173
"""
1176
1174
1177
- if not use_origin_backend (x1 ) and not kwargs :
1178
- if not isinstance (x1 , dparray ):
1179
- pass
1180
- else :
1181
- return dpnp_nancumsum (x1 )
1175
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1176
+ if x1_desc and not kwargs :
1177
+ return dpnp_nancumsum (x1_desc )
1182
1178
1183
1179
return call_origin (numpy .nancumsum , x1 , ** kwargs )
1184
1180
@@ -1206,9 +1202,8 @@ def nanprod(x1, **kwargs):
1206
1202
1207
1203
"""
1208
1204
1209
- is_x1_dparray = isinstance (x1 , dparray )
1210
-
1211
- if (not use_origin_backend (x1 ) and is_x1_dparray and not kwargs ):
1205
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1206
+ if x1_desc and not kwargs :
1212
1207
return dpnp_nanprod (x1 )
1213
1208
1214
1209
return call_origin (numpy .nanprod , x1 , ** kwargs )
@@ -1237,9 +1232,8 @@ def nansum(x1, **kwargs):
1237
1232
1238
1233
"""
1239
1234
1240
- is_x1_dparray = isinstance (x1 , dparray )
1241
-
1242
- if (not use_origin_backend (x1 ) and is_x1_dparray and not kwargs ):
1235
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1236
+ if x1_desc and not kwargs :
1243
1237
return dpnp_nansum (x1 )
1244
1238
1245
1239
return call_origin (numpy .nansum , x1 , ** kwargs )
@@ -1360,16 +1354,15 @@ def prod(x1, axis=None, dtype=None, out=None, keepdims=False, initial=None, wher
1360
1354
1361
1355
"""
1362
1356
1363
- if not use_origin_backend (x1 ):
1364
- if not isinstance (x1 , dparray ):
1365
- pass
1366
- elif out is not None and not isinstance (out , dparray ):
1357
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1358
+ if x1_desc :
1359
+ if out is not None and not isinstance (out , dparray ):
1367
1360
pass
1368
1361
elif where is not True :
1369
1362
pass
1370
1363
else :
1371
- result_obj = dpnp_prod (x1 , axis , dtype , out , keepdims , initial , where )
1372
- result = dpnp .convert_single_elem_array_to_scalar (result_obj , keepdims )
1364
+ result_obj = dpnp_prod (x1_desc , axis , dtype , out , keepdims , initial , where )
1365
+ result = dpnp .convert_single_elem_array_to_scalar (result_obj , keepdims )
1373
1366
1374
1367
return result
1375
1368
@@ -1540,23 +1533,22 @@ def sum(x1, axis=None, dtype=None, out=None, keepdims=False, initial=None, where
1540
1533
1541
1534
"""
1542
1535
1543
- if not use_origin_backend (x1 ):
1544
- if not isinstance (x1 , dparray ):
1545
- pass
1546
- elif out is not None and not isinstance (out , dparray ):
1536
+ x1_desc = dpnp .get_dpnp_descriptor (x1 )
1537
+ if x1_desc :
1538
+ if out is not None and not isinstance (out , dparray ):
1547
1539
pass
1548
1540
elif where is not True :
1549
1541
pass
1550
1542
else :
1551
- result_obj = dpnp_sum (x1 , axis , dtype , out , keepdims , initial , where )
1543
+ result_obj = dpnp_sum (x1_desc , axis , dtype , out , keepdims , initial , where )
1552
1544
result = dpnp .convert_single_elem_array_to_scalar (result_obj , keepdims )
1553
1545
1554
1546
return result
1555
1547
1556
1548
return call_origin (numpy .sum , x1 , axis = axis , dtype = dtype , out = out , keepdims = keepdims , initial = initial , where = where )
1557
1549
1558
1550
1559
- def trapz (y , x = None , dx = 1.0 , ** kwargs ):
1551
+ def trapz (y , x = None , dx = 1.0 , axis = - 1 ):
1560
1552
"""
1561
1553
Integrate along the given axis using the composite trapezoidal rule.
1562
1554
@@ -1583,25 +1575,23 @@ def trapz(y, x=None, dx=1.0, **kwargs):
1583
1575
1584
1576
"""
1585
1577
1586
- if not use_origin_backend (y ):
1587
-
1588
- if not isinstance (y , dparray ):
1589
- pass
1590
- elif not isinstance (x , dparray ) and x is not None :
1578
+ y_desc = dpnp .get_dpnp_descriptor (y )
1579
+ if y_desc :
1580
+ if not isinstance (x , dparray ) and x is not None :
1591
1581
pass
1592
- elif x is not None and y .size != x .size :
1582
+ elif x is not None and y_desc .size != x .size :
1593
1583
pass
1594
- elif x is not None and y .shape != x .shape :
1584
+ elif x is not None and y_desc .shape != x .shape :
1595
1585
pass
1596
- elif y .ndim > 1 :
1586
+ elif y_desc .ndim > 1 :
1597
1587
pass
1598
1588
else :
1599
1589
if x is None :
1600
- x = dpnp .empty (0 , dtype = y .dtype )
1590
+ x = dpnp .empty (0 , dtype = y_desc .dtype )
1601
1591
1602
- return dpnp_trapz (y , x , dx )
1592
+ return dpnp_trapz (y_desc , x , dx )
1603
1593
1604
- return call_origin (numpy .trapz , y , x = x , dx = dx , ** kwargs )
1594
+ return call_origin (numpy .trapz , y , x , dx , axis )
1605
1595
1606
1596
1607
1597
def true_divide (* args , ** kwargs ):
0 commit comments