@@ -159,6 +159,7 @@ def __and__(self, other):
159
159
# '__array_wrap__',
160
160
161
161
def __bool__ (self ):
162
+ """``True`` if self else ``False``."""
162
163
return self ._array_obj .__bool__ ()
163
164
164
165
# '__class__',
@@ -185,12 +186,47 @@ def __copy__(self):
185
186
# '__doc__',
186
187
187
188
def __dlpack__ (self , stream = None ):
189
+ """
190
+ Produces DLPack capsule.
191
+
192
+ Parameters
193
+ ----------
194
+ stream : {:class:`dpctl.SyclQueue`, None}, optional
195
+ Execution queue to synchronize with. If ``None``,
196
+ synchronization is not performed.
197
+
198
+ Raises
199
+ ------
200
+ MemoryError
201
+ when host memory can not be allocated.
202
+ DLPackCreationError
203
+ when array is allocated on a partitioned
204
+ SYCL device, or with a non-default context.
205
+
206
+ """
207
+
188
208
return self ._array_obj .__dlpack__ (stream = stream )
189
209
190
210
def __dlpack_device__ (self ):
211
+ """
212
+ Gives a tuple (``device_type``, ``device_id``) corresponding to
213
+ ``DLDevice`` entry in ``DLTensor`` in DLPack protocol.
214
+
215
+ The tuple describes the non-partitioned device where the array has been
216
+ allocated, or the non-partitioned parent device of the allocation
217
+ device.
218
+
219
+ Raises
220
+ ------
221
+ DLPackCreationError:
222
+ when the ``device_id`` could not be determined.
223
+
224
+ """
225
+
191
226
return self ._array_obj .__dlpack_device__ ()
192
227
193
228
def __eq__ (self , other ):
229
+ """Return ``self==value``."""
194
230
return dpnp .equal (self , other )
195
231
196
232
def __float__ (self ):
@@ -203,6 +239,7 @@ def __floordiv__(self, other):
203
239
# '__format__',
204
240
205
241
def __ge__ (self , other ):
242
+ """Return ``self>=value``."""
206
243
return dpnp .greater_equal (self , other )
207
244
208
245
# '__getattribute__',
@@ -224,6 +261,7 @@ def __getitem__(self, key):
224
261
return res
225
262
226
263
def __gt__ (self , other ):
264
+ """Return ``self>value``."""
227
265
return dpnp .greater (self , other )
228
266
229
267
# '__hash__',
@@ -306,21 +344,23 @@ def __ixor__(self, other):
306
344
return self
307
345
308
346
def __le__ (self , other ):
347
+ """Return ``self<=value``."""
309
348
return dpnp .less_equal (self , other )
310
349
311
350
def __len__ (self ):
312
351
"""Return ``len(self)``."""
313
-
314
352
return self ._array_obj .__len__ ()
315
353
316
354
def __lshift__ (self , other ):
317
355
"""Return ``self<<value``."""
318
356
return dpnp .left_shift (self , other )
319
357
320
358
def __lt__ (self , other ):
359
+ """Return ``self<value``."""
321
360
return dpnp .less (self , other )
322
361
323
362
def __matmul__ (self , other ):
363
+ """Return ``self@value``."""
324
364
return dpnp .matmul (self , other )
325
365
326
366
def __mod__ (self , other ):
@@ -332,6 +372,7 @@ def __mul__(self, other):
332
372
return dpnp .multiply (self , other )
333
373
334
374
def __ne__ (self , other ):
375
+ """Return ``self!=value``."""
335
376
return dpnp .not_equal (self , other )
336
377
337
378
def __neg__ (self ):
@@ -363,6 +404,7 @@ def __rand__(self, other):
363
404
# '__reduce_ex__',
364
405
365
406
def __repr__ (self ):
407
+ """Return ``repr(self)``."""
366
408
return dpt .usm_ndarray_repr (self ._array_obj , prefix = "array" )
367
409
368
410
def __rfloordiv__ (self , other ):
@@ -417,18 +459,7 @@ def __setitem__(self, key, val):
417
459
# '__sizeof__',
418
460
419
461
def __str__ (self ):
420
- """
421
- Output values from the array to standard output.
422
-
423
- Examples
424
- --------
425
- >>> print(a)
426
- [[ 136. 136. 136.]
427
- [ 272. 272. 272.]
428
- [ 408. 408. 408.]]
429
-
430
- """
431
-
462
+ """Return ``str(self)``."""
432
463
return self ._array_obj .__str__ ()
433
464
434
465
def __sub__ (self , other ):
@@ -1060,12 +1091,12 @@ def real(self):
1060
1091
array([1. , 0.70710677])
1061
1092
1062
1093
"""
1094
+
1063
1095
if dpnp .issubsctype (self .dtype , dpnp .complexfloating ):
1064
1096
return dpnp_array ._create_from_usm_ndarray (
1065
1097
dpnp .get_usm_ndarray (self ).real
1066
1098
)
1067
- else :
1068
- return self
1099
+ return self
1069
1100
1070
1101
@real .setter
1071
1102
def real (self , value ):
@@ -1083,6 +1114,7 @@ def real(self, value):
1083
1114
array([9.+2.j, 9.+4.j, 9.+6.j])
1084
1115
1085
1116
"""
1117
+
1086
1118
dpnp .copyto (self ._array_obj .real , value )
1087
1119
1088
1120
def repeat (self , repeats , axis = None ):
@@ -1152,7 +1184,8 @@ def searchsorted(self, v, side="left", sorter=None):
1152
1184
1153
1185
@property
1154
1186
def shape (self ):
1155
- """Lengths of axes. A tuple of numbers represents size of each dimension.
1187
+ """
1188
+ Lengths of axes. A tuple of numbers represents size of each dimension.
1156
1189
1157
1190
Setter of this property involves reshaping without copy. If the array
1158
1191
cannot be reshaped without copy, it raises an exception.
@@ -1181,7 +1214,6 @@ def shape(self, newshape):
1181
1214
@property
1182
1215
def size (self ):
1183
1216
"""Number of elements in the array."""
1184
-
1185
1217
return self ._array_obj .size
1186
1218
1187
1219
def sort (self , axis = - 1 , kind = None , order = None ):
@@ -1250,14 +1282,12 @@ def std(
1250
1282
@property
1251
1283
def strides (self ):
1252
1284
"""
1253
- Get strides of an array.
1254
-
1255
1285
Returns memory displacement in array elements, upon unit
1256
1286
change of respective index.
1257
1287
1258
- E.g. for strides (s1, s2, s3) and multi-index (i1, i2, i3)
1259
-
1260
- a[i1, i2, i3] == (&a[0,0,0])[ s1*s1 + s2*i2 + s3*i3]
1288
+ For example, for strides `` (s1, s2, s3)`` and multi-index
1289
+ ``(i1, i2, i3)`` position of the respective element relative
1290
+ to zero multi-index element is `` s1*s1 + s2*i2 + s3*i3``.
1261
1291
1262
1292
"""
1263
1293
@@ -1403,6 +1433,7 @@ def var(
1403
1433
Refer to :obj:`dpnp.var` for full documentation.
1404
1434
1405
1435
"""
1436
+
1406
1437
return dpnp .var (self , axis , dtype , out , ddof , keepdims , where = where )
1407
1438
1408
1439
0 commit comments