@@ -373,7 +373,15 @@ def astype(self, dtype, order='K', casting='unsafe', subok=True, copy=True):
373373
374374 # 'base',
375375 # 'byteswap',
376- # 'choose',
376+
377+ def choose (input , choices , out = None , mode = 'raise' ):
378+ """
379+ Construct an array from an index array and a set of arrays to choose from.
380+
381+ """
382+
383+ return dpnp .choose (input , choices , out , mode )
384+
377385 # 'clip',
378386 # 'compress',
379387
@@ -408,7 +416,19 @@ def conjugate(self):
408416 # 'cumprod',
409417 # 'cumsum',
410418 # 'data',
411- # 'diagonal',
419+
420+ def diagonal (input , offset = 0 , axis1 = 0 , axis2 = 1 ):
421+ """
422+ Return specified diagonals.
423+
424+ See Also
425+ --------
426+ :obj:`dpnp.diagonal`
427+
428+ """
429+
430+ return dpnp .diagonal (input , offset , axis1 , axis2 )
431+
412432 # 'dot',
413433
414434 @property
@@ -420,7 +440,32 @@ def dtype(self):
420440
421441 # 'dump',
422442 # 'dumps',
423- # 'fill',
443+
444+ def fill (self , value ):
445+ """
446+ Fill the array with a scalar value.
447+
448+ Parameters
449+ ----------
450+ value : scalar
451+ All elements of `a` will be assigned this value.
452+
453+ Examples
454+ --------
455+ >>> a = np.array([1, 2])
456+ >>> a.fill(0)
457+ >>> a
458+ array([0, 0])
459+ >>> a = np.empty(2)
460+ >>> a.fill(1)
461+ >>> a
462+ array([1., 1.])
463+
464+ """
465+
466+ for i in range (self .size ):
467+ self .flat [i ] = value
468+
424469 # 'flags',
425470
426471 @property
@@ -465,7 +510,40 @@ def flatten(self, order='C'):
465510
466511 # 'getfield',
467512 # 'imag',
468- # 'item',
513+
514+ def item (self , id = None ):
515+ """
516+ Copy an element of an array to a standard Python scalar and return it.
517+
518+ For full documentation refer to :obj:`numpy.ndarray.item`.
519+
520+ Examples
521+ --------
522+ >>> np.random.seed(123)
523+ >>> x = np.random.randint(9, size=(3, 3))
524+ >>> x
525+ array([[2, 2, 6],
526+ [1, 3, 6],
527+ [1, 0, 1]])
528+ >>> x.item(3)
529+ 1
530+ >>> x.item(7)
531+ 0
532+ >>> x.item((0, 1))
533+ 2
534+ >>> x.item((2, 2))
535+ 1
536+
537+ """
538+
539+ if id is None :
540+ if self .size != 1 :
541+ raise ValueError ("DPNP dparray::item(): can only convert an array of size 1 to a Python scalar" )
542+ else :
543+ id = 0
544+
545+ return self .flat [id ]
546+
469547 # 'itemset',
470548
471549 @property
@@ -514,9 +592,50 @@ def ndim(self):
514592 # 'ravel',
515593 # 'real',
516594 # 'repeat',
517- # 'reshape',
595+
596+ def reshape (self , d0 , * dn , order = b'C' ):
597+ """
598+ Returns an array containing the same data with a new shape.
599+
600+ Refer to `dpnp.reshape` for full documentation.
601+
602+ .. seealso::
603+ :meth:`numpy.ndarray.reshape`
604+
605+ Notes
606+ -----
607+ Unlike the free function `dpnp.reshape`, this method on `ndarray` allows
608+ the elements of the shape parameter to be passed in as separate arguments.
609+ For example, ``a.reshape(10, 11)`` is equivalent to
610+ ``a.reshape((10, 11))``.
611+
612+ """
613+
614+ if dn :
615+ if not isinstance (d0 , int ):
616+ msg_tmpl = "'{}' object cannot be interpreted as an integer"
617+ raise TypeError (msg_tmpl .format (type (d0 ).__name__ ))
618+ shape = [d0 , * dn ]
619+ else :
620+ shape = d0
621+
622+ shape_tup = dpnp .dpnp_utils ._object_to_tuple (shape )
623+
624+ return dpnp .reshape (self , shape_tup )
625+
518626 # 'resize',
519- # 'round',
627+
628+ def round (self , decimals = 0 , out = None ):
629+ """
630+ Return array with each element rounded to the given number of decimals.
631+
632+ .. seealso::
633+ :obj:`dpnp.around` for full documentation.
634+
635+ """
636+
637+ return dpnp .around (self , decimals , out )
638+
520639 # 'searchsorted',
521640 # 'setfield',
522641 # 'setflags',
@@ -561,7 +680,17 @@ def size(self):
561680 return self ._array_obj .size
562681
563682 # 'sort',
564- # 'squeeze',
683+
684+ def squeeze (self , axis = None ):
685+ """
686+ Remove single-dimensional entries from the shape of an array.
687+
688+ .. seealso::
689+ :obj:`dpnp.squeeze` for full documentation
690+
691+ """
692+
693+ return dpnp .squeeze (self , axis )
565694
566695 def std (self , axis = None , dtype = None , out = None , ddof = 0 , keepdims = False ):
567696 """ Returns the variance of the array elements, along given axis.
@@ -580,15 +709,37 @@ def strides(self):
580709
581710 return self ._array_obj .strides
582711
583- # 'sum',
712+ def sum (self , axis = None , dtype = None , out = None , keepdims = False , initial = 0 , where = True ):
713+ """
714+ Returns the sum along a given axis.
715+
716+ .. seealso::
717+ :obj:`dpnp.sum` for full documentation,
718+ :meth:`dpnp.dparray.sum`
719+
720+ """
721+
722+ return dpnp .sum (self , axis , dtype , out , keepdims , initial , where )
723+
584724 # 'swapaxes',
585725 # 'take',
586726 # 'tobytes',
587727 # 'tofile',
588728 # 'tolist',
589729 # 'tostring',
590730 # 'trace',
591- # 'transpose',
731+
732+ def transpose (self , * axes ):
733+ """
734+ Returns a view of the array with axes permuted.
735+
736+ .. seealso::
737+ :obj:`dpnp.transpose` for full documentation,
738+ :meth:`numpy.ndarray.reshape`
739+
740+ """
741+
742+ return dpnp .transpose (self , axes )
743+
592744 # 'var',
593745 # 'view'
594-
0 commit comments