@@ -839,41 +839,45 @@ def flatten(self, order="C"):
839
839
"""
840
840
Return a copy of the array collapsed into one dimension.
841
841
842
+ For full documentation refer to :obj:`numpy.ndarray.flatten`.
843
+
842
844
Parameters
843
845
----------
844
- order: {'C', 'F', 'A', 'K'}, optional
845
- 'C' means to flatten in row-major (C-style) order.
846
- 'F' means to flatten in column-major (Fortran- style) order.
847
- 'A' means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise.
848
- 'K' means to flatten a in the order the elements occur in memory. The default is 'C'.
846
+ order : {"C", "F"}, optional
847
+ Read the elements using this index order, and place the elements
848
+ into the reshaped array using this index order.
849
+
850
+ - "C" means to read / write the elements using C-like index
851
+ order, with the last axis index changing fastest, back to the
852
+ first axis index changing slowest.
853
+ - "F" means to read / write the elements using Fortran-like
854
+ index order, with the first index changing fastest, and the
855
+ last index changing slowest.
856
+
857
+ The default is ``"C"``.
849
858
850
859
Returns
851
860
-------
852
- out: ndarray
861
+ out: dpnp. ndarray
853
862
A copy of the input array, flattened to one dimension.
854
863
855
864
See Also
856
865
--------
857
- :obj:`dpnp.ravel`, :obj:`dpnp.flat`
866
+ :obj:`dpnp.ravel` : Return a flattened array.
867
+ :obj:`dpnp.flat` : A 1-D flat iterator over the array.
858
868
859
- """
860
- new_arr = self .__new__ (dpnp_array )
861
- new_arr ._array_obj = dpt .empty (
862
- self .shape ,
863
- dtype = self .dtype ,
864
- order = order ,
865
- device = self ._array_obj .sycl_device ,
866
- usm_type = self ._array_obj .usm_type ,
867
- sycl_queue = self ._array_obj .sycl_queue ,
868
- )
869
+ Examples
870
+ --------
871
+ >>> import dpnp as np
872
+ >>> a = np.array([[1, 2], [3, 4]])
873
+ >>> a.flatten()
874
+ array([1, 2, 3, 4])
875
+ >>> a.flatten("F")
876
+ array([1, 3, 2, 4])
869
877
870
- if self .size > 0 :
871
- dpt ._copy_utils ._copy_from_usm_ndarray_to_usm_ndarray (
872
- new_arr ._array_obj , self ._array_obj
873
- )
874
- new_arr ._array_obj = dpt .reshape (new_arr ._array_obj , (self .size ,))
878
+ """
875
879
876
- return new_arr
880
+ return self . reshape ( - 1 , order = order , copy = True )
877
881
878
882
# 'getfield',
879
883
0 commit comments