@@ -113,15 +113,18 @@ def nanargmax(a, axis=None, out=None, *, keepdims=False):
113
113
Input array.
114
114
axis : {None, int}, optional
115
115
Axis along which to operate. By default flattened input is used.
116
+
116
117
Default: ``None``.
117
118
out : {None, dpnp.ndarray, usm_ndarray}, optional
118
119
If provided, the result will be inserted into this array. It should be
119
120
of the appropriate shape and dtype.
121
+
120
122
Default: ``None``.
121
123
keepdims : {None, bool}, optional
122
124
If this is set to ``True``, the axes which are reduced are left in the
123
125
result as dimensions with size one. With this option, the result will
124
126
broadcast correctly against the array.
127
+
125
128
Default: ``False``.
126
129
127
130
Returns
@@ -184,15 +187,18 @@ def nanargmin(a, axis=None, out=None, *, keepdims=False):
184
187
Input array.
185
188
axis : {None, int}, optional
186
189
Axis along which to operate. By default flattened input is used.
190
+
187
191
Default: ``None``.
188
192
out : {None, dpnp.ndarray, usm_ndarray}, optional
189
193
If provided, the result will be inserted into this array. It should be
190
194
of the appropriate shape and dtype.
195
+
191
196
Default: ``None``.
192
197
keepdims : {None, bool}, optional
193
198
If this is set to ``True``, the axes which are reduced are left in the
194
199
result as dimensions with size one. With this option, the result will
195
200
broadcast correctly against the array.
201
+
196
202
Default: ``False``.
197
203
198
204
Returns
@@ -257,19 +263,24 @@ def nancumprod(a, axis=None, dtype=None, out=None):
257
263
Input array.
258
264
axis : {None, int}, optional
259
265
Axis along which the cumulative product is computed. The default
260
- (``None``) is to compute the cumulative product over the flattened
261
- array.
266
+ is to compute the cumulative product over the flattened array.
267
+
268
+ Default: ``None``.
262
269
dtype : {None, dtype}, optional
263
270
Type of the returned array and of the accumulator in which the elements
264
271
are summed. If `dtype` is not specified, it defaults to the dtype of
265
272
`a`, unless `a` has an integer dtype with a precision less than that of
266
273
the default platform integer. In that case, the default platform
267
274
integer is used.
275
+
276
+ Default: ``None``.
268
277
out : {None, dpnp.ndarray, usm_ndarray}, optional
269
278
Alternative output array in which to place the result. It must have the
270
279
same shape and buffer length as the expected output but the type will
271
280
be cast if necessary.
272
281
282
+ Default: ``None``.
283
+
273
284
Returns
274
285
-------
275
286
out : dpnp.ndarray
@@ -321,19 +332,25 @@ def nancumsum(a, axis=None, dtype=None, out=None):
321
332
a : {dpnp.ndarray, usm_ndarray}
322
333
Input array.
323
334
axis : {None, int}, optional
324
- Axis along which the cumulative sum is computed. The default (``None``)
325
- is to compute the cumulative sum over the flattened array.
335
+ Axis along which the cumulative sum is computed. The default is to
336
+ compute the cumulative sum over the flattened array.
337
+
338
+ Default: ``None``.
326
339
dtype : {None, dtype}, optional
327
340
Type of the returned array and of the accumulator in which the elements
328
341
are summed. If `dtype` is not specified, it defaults to the dtype of
329
342
`a`, unless `a` has an integer dtype with a precision less than that of
330
343
the default platform integer. In that case, the default platform
331
344
integer is used.
345
+
346
+ Default: ``None``.
332
347
out : {None, dpnp.ndarray, usm_ndarray}, optional
333
348
Alternative output array in which to place the result. It must have the
334
349
same shape and buffer length as the expected output but the type will
335
350
be cast if necessary.
336
351
352
+ Default: ``None``.
353
+
337
354
Returns
338
355
-------
339
356
out : dpnp.ndarray
@@ -386,15 +403,19 @@ def nanmax(a, axis=None, out=None, keepdims=False, initial=None, where=True):
386
403
Axis or axes along which maximum values must be computed. By default,
387
404
the maximum value must be computed over the entire array. If a tuple
388
405
of integers, maximum values must be computed over multiple axes.
406
+
389
407
Default: ``None``.
390
408
out : {None, dpnp.ndarray, usm_ndarray}, optional
391
409
If provided, the result will be inserted into this array. It should
392
410
be of the appropriate shape and dtype.
411
+
412
+ Default: ``None``.
393
413
keepdims : {None, bool}, optional
394
414
If ``True``, the reduced axes (dimensions) must be included in the
395
415
result as singleton dimensions, and, accordingly, the result must be
396
416
compatible with the input array. Otherwise, if ``False``, the reduced
397
417
axes (dimensions) must not be included in the result.
418
+
398
419
Default: ``False``.
399
420
400
421
Returns
@@ -476,6 +497,7 @@ def nanmean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
476
497
Axis or axes along which the arithmetic means must be computed. If
477
498
a tuple of unique integers, the means are computed over multiple
478
499
axes. If ``None``, the mean is computed over the entire array.
500
+
479
501
Default: ``None``.
480
502
dtype : {None, dtype}, optional
481
503
Type to use in computing the mean. By default, if `a` has a
@@ -484,16 +506,22 @@ def nanmean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
484
506
If `a` has a boolean or integral data type, the returned array
485
507
will have the default floating point data type for the device
486
508
where input array `a` is allocated.
509
+
510
+ Default: ``None``.
487
511
out : {None, dpnp.ndarray, usm_ndarray}, optional
488
512
Alternative output array in which to place the result. It must have
489
513
the same shape as the expected output but the type (of the calculated
490
- values) will be cast if necessary. Default: ``None``.
514
+ values) will be cast if necessary.
515
+
516
+ Default: ``None``.
491
517
keepdims : {None, bool}, optional
492
518
If ``True``, the reduced axes (dimensions) are included in the result
493
519
as singleton dimensions, so that the returned array remains
494
520
compatible with the input array according to Array Broadcasting
495
521
rules. Otherwise, if ``False``, the reduced axes are not included in
496
- the returned array. Default: ``False``.
522
+ the returned array.
523
+
524
+ Default: ``False``.
497
525
498
526
Returns
499
527
-------
@@ -588,25 +616,29 @@ def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=False):
588
616
the array. If a sequence of axes, the array is first flattened along
589
617
the given axes, then the median is computed along the resulting
590
618
flattened axis.
619
+
591
620
Default: ``None``.
592
621
out : {None, dpnp.ndarray, usm_ndarray}, optional
593
622
Alternative output array in which to place the result. It must have
594
623
the same shape as the expected output but the type (of the calculated
595
624
values) will be cast if necessary.
625
+
596
626
Default: ``None``.
597
627
overwrite_input : bool, optional
598
628
If ``True``, then allow use of memory of input array `a` for
599
629
calculations. The input array will be modified by the call to
600
630
:obj:`dpnp.nanmedian`. This will save memory when you do not need to
601
631
preserve the contents of the input array. Treat the input as undefined,
602
632
but it will probably be fully or partially sorted.
633
+
603
634
Default: ``False``.
604
635
keepdims : bool, optional
605
636
If ``True``, the reduced axes (dimensions) are included in the result
606
637
as singleton dimensions, so that the returned array remains
607
638
compatible with the input array according to Array Broadcasting
608
639
rules. Otherwise, if ``False``, the reduced axes are not included in
609
640
the returned array.
641
+
610
642
Default: ``False``.
611
643
612
644
Returns
@@ -687,15 +719,19 @@ def nanmin(a, axis=None, out=None, keepdims=False, initial=None, where=True):
687
719
Axis or axes along which minimum values must be computed. By default,
688
720
the minimum value must be computed over the entire array. If a tuple
689
721
of integers, minimum values must be computed over multiple axes.
722
+
690
723
Default: ``None``.
691
724
out : {None, dpnp.ndarray, usm_ndarray}, optional
692
725
If provided, the result will be inserted into this array. It should
693
726
be of the appropriate shape and dtype.
727
+
728
+ Default: ``None``.
694
729
keepdims : {None, bool}, optional
695
730
If ``True``, the reduced axes (dimensions) must be included in the
696
731
result as singleton dimensions, and, accordingly, the result must be
697
732
compatible with the input array. Otherwise, if ``False``, the reduced
698
733
axes (dimensions) must not be included in the result.
734
+
699
735
Default: ``False``.
700
736
701
737
Returns
@@ -785,6 +821,7 @@ def nanprod(
785
821
axis : {None, int or tuple of ints}, optional
786
822
Axis or axes along which the product is computed. The default is to
787
823
compute the product of the flattened array.
824
+
788
825
Default: ``None``.
789
826
dtype : {None, dtype}, optional
790
827
The type of the returned array and of the accumulator in which the
@@ -793,17 +830,20 @@ def nanprod(
793
830
the platform (u)intp. In that case, the default will be either (u)int32
794
831
or (u)int64 depending on whether the platform is 32 or 64 bits. For
795
832
inexact inputs, dtype must be inexact.
833
+
796
834
Default: ``None``.
797
835
out : {None, dpnp.ndarray, usm_ndarray}, optional
798
836
Alternate output array in which to place the result. If provided, it
799
837
must have the same shape as the expected output, but the type will be
800
838
cast if necessary. The casting of NaN to integer
801
839
can yield unexpected results.
840
+
802
841
Default: ``None``.
803
842
keepdims : {None, bool}, optional
804
843
If ``True``, the axes which are reduced are left in the result as
805
844
dimensions with size one. With this option, the result will broadcast
806
845
correctly against the original `a`.
846
+
807
847
Default: ``False``.
808
848
809
849
Returns
@@ -878,6 +918,7 @@ def nansum(
878
918
axis : {None, int or tuple of ints}, optional
879
919
Axis or axes along which the sum is computed. The default is to compute
880
920
the sum of the flattened array.
921
+
881
922
Default: ``None``.
882
923
dtype : {None, dtype}, optional
883
924
The type of the returned array and of the accumulator in which the
@@ -886,17 +927,20 @@ def nansum(
886
927
(u)intp. In that case, the default will be either (u)int32 or (u)int64
887
928
depending on whether the platform is 32 or 64 bits. For inexact inputs,
888
929
dtype must be inexact.
930
+
889
931
Default: ``None``.
890
932
out : {None, dpnp.ndarray, usm_ndarray}, optional
891
933
Alternate output array in which to place the result. If provided, it
892
934
must have the same shape as the expected output, but the type will be
893
935
cast if necessary. The casting of NaN to integer can yield unexpected
894
936
results.
937
+
895
938
Default: ``None``.
896
939
keepdims : {None, bool}, optional
897
940
If this is set to ``True``, the axes which are reduced are left in the
898
941
result as dimensions with size one. With this option, the result will
899
942
broadcast correctly against the original `a`.
943
+
900
944
Default: ``False``.
901
945
902
946
Returns
@@ -966,6 +1010,7 @@ def nanstd(
966
1010
* ,
967
1011
where = True ,
968
1012
mean = None ,
1013
+ correction = None ,
969
1014
):
970
1015
"""
971
1016
Compute the standard deviation along the specified axis,
@@ -1018,6 +1063,12 @@ def nanstd(
1018
1063
1019
1064
Default: ``None``.
1020
1065
1066
+ correction : {None, int, float}, optional
1067
+ Array API compatible name for the `ddof` parameter. Only one of them
1068
+ can be provided at the same time.
1069
+
1070
+ Default: ``None``.
1071
+
1021
1072
Returns
1022
1073
-------
1023
1074
out : dpnp.ndarray
@@ -1094,6 +1145,7 @@ def nanstd(
1094
1145
keepdims = keepdims ,
1095
1146
where = where ,
1096
1147
mean = mean ,
1148
+ correction = correction ,
1097
1149
)
1098
1150
return dpnp .sqrt (res , out = res )
1099
1151
@@ -1108,6 +1160,7 @@ def nanvar(
1108
1160
* ,
1109
1161
where = True ,
1110
1162
mean = None ,
1163
+ correction = None ,
1111
1164
):
1112
1165
"""
1113
1166
Compute the variance along the specified axis, while ignoring NaNs.
@@ -1158,6 +1211,12 @@ def nanvar(
1158
1211
1159
1212
Default: ``None``.
1160
1213
1214
+ correction : {None, int, float}, optional
1215
+ Array API compatible name for the `ddof` parameter. Only one of them
1216
+ can be provided at the same time.
1217
+
1218
+ Default: ``None``.
1219
+
1161
1220
Returns
1162
1221
-------
1163
1222
out : dpnp.ndarray
@@ -1231,6 +1290,7 @@ def nanvar(
1231
1290
ddof = ddof ,
1232
1291
keepdims = keepdims ,
1233
1292
where = where ,
1293
+ correction = correction ,
1234
1294
)
1235
1295
1236
1296
if dtype is not None :
@@ -1243,6 +1303,13 @@ def nanvar(
1243
1303
if not dpnp .issubdtype (out .dtype , dpnp .inexact ):
1244
1304
raise TypeError ("If input is inexact, then out must be inexact." )
1245
1305
1306
+ if correction is not None :
1307
+ if ddof != 0 :
1308
+ raise ValueError (
1309
+ "ddof and correction can't be provided simultaneously."
1310
+ )
1311
+ ddof = correction
1312
+
1246
1313
# Compute mean
1247
1314
cnt = dpnp .sum (
1248
1315
~ mask , axis = axis , dtype = dpnp .intp , keepdims = True , where = where
0 commit comments