From ef93c932c7c951cca88c6775684b451cbffc68a7 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 19 Jul 2023 11:13:39 +0200 Subject: [PATCH 1/9] Update API Reference --- doc/reference/comparison.rst | 6 +-- doc/reference/creation.rst | 18 ++++++++- doc/reference/dtype.rst | 56 ++++++++++++++++++++++++++ doc/reference/indexing.rst | 72 ++++++++++++++++++++++++++++++++++ doc/reference/linalg.rst | 17 ++------ doc/reference/manipulation.rst | 17 ++++++-- doc/reference/math.rst | 39 +++++++++++++++--- doc/reference/misc.rst | 5 +++ doc/reference/random.rst | 1 - doc/reference/routines.rst | 2 + doc/reference/sorting.rst | 1 + doc/reference/statistics.rst | 18 +++++---- doc/reference/ufunc.rst | 3 ++ 13 files changed, 219 insertions(+), 36 deletions(-) create mode 100644 doc/reference/dtype.rst create mode 100644 doc/reference/indexing.rst diff --git a/doc/reference/comparison.rst b/doc/reference/comparison.rst index b42eecc1518d..d7157d8ff0b8 100644 --- a/doc/reference/comparison.rst +++ b/doc/reference/comparison.rst @@ -1,7 +1,7 @@ -Comparison Table -================ +Comparison Table NumPy/ DPNP/ CuPy +================================== -Here is a list of NumPy APIs and its corresponding DPNP implementations. +Here is a list of NumPy and CuPy APIs and its corresponding DPNP implementations. ``-`` in DPNP column means that DPNP implementation is not provided yet. diff --git a/doc/reference/creation.rst b/doc/reference/creation.rst index 57d1e5d41d24..0ab30d2e9a28 100644 --- a/doc/reference/creation.rst +++ b/doc/reference/creation.rst @@ -20,7 +20,6 @@ Basic creation routines dpnp.zeros_like dpnp.full dpnp.full_like - dpnp.vander Creation from other data @@ -35,7 +34,13 @@ Creation from other data dpnp.asanyarray dpnp.ascontiguousarray dpnp.copy + dpnp.frombuffer + dpnp.from_dlpack dpnp.fromfile + dpnp.fromfunction + dpnp.fromiter + dpnp.fromstring + dpnp.loadtxt Numerical ranges @@ -66,3 +71,14 @@ Matrix creation dpnp.tri dpnp.tril dpnp.triu + dpnp.vander + + +The Matrix class +---------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.mat + dpnp.bmat diff --git a/doc/reference/dtype.rst b/doc/reference/dtype.rst new file mode 100644 index 000000000000..7dbc491fdcd4 --- /dev/null +++ b/doc/reference/dtype.rst @@ -0,0 +1,56 @@ +Data type routines +================== + +.. https://docs.scipy.org/doc/numpy/reference/routines.dtype.html + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.can_cast + dpnp.promote_types + dpnp.min_scalar_type + dpnp.result_type + dpnp.common_type + dpnp.obj2sctype + +Creating data types +------------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.dtype + dpnp.format_parser + +Data type information +--------------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.finfo + dpnp.iinfo + +Data type testing +----------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.issctype + dpnp.issubdtype + dpnp.issubsctype + dpnp.issubclass_ + dpnp.find_common_type + +Miscellaneous +------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.typename + dpnp.sctype2char + dpnp.mintypecode + dpnp.maximum_sctype diff --git a/doc/reference/indexing.rst b/doc/reference/indexing.rst new file mode 100644 index 000000000000..0cc64b995dec --- /dev/null +++ b/doc/reference/indexing.rst @@ -0,0 +1,72 @@ +Array Indexing Routines +======================= + +.. https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html + +Generating index arrays +----------------------- + + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.c_ + dpnp.r_ + dpnp.s_ + dpnp.nonzero + dpnp.where + dpnp.indices + dpnp.ix_ + dpnp.ogrid + dpnp.ravel_multi_index + dpnp.unravel_index + dpnp.diag_indices + dpnp.diag_indices_from + dpnp.mask_indices + dpnp.tril_indices + dpnp.tril_indices_from + dpnp.triu_indices + dpnp.triu_indices_from + + +Indexing-like operations +------------------------ +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.take + dpnp.take_along_axis + dpnp.choose + dpnp.compress + dpnp.diag + dpnp.diagonal + dpnp.select + + +Inserting data into arrays +-------------------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.place + dpnp.put + dpnp.put_along_axis + dpnp.putmask + dpnp.fill_diagonal + + +Iterating over arrays +--------------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.nditer + dpnp.ndenumerate + dpnp.ndindex + dpnp.nested_iters + dpnp.flatiter + dpnp.iterable diff --git a/doc/reference/linalg.rst b/doc/reference/linalg.rst index 00c1332c9acb..e85f6a1ee2ce 100644 --- a/doc/reference/linalg.rst +++ b/doc/reference/linalg.rst @@ -10,7 +10,6 @@ Matrix and vector products :toctree: generated/ :nosignatures: - dpnp.cross dpnp.dot dpnp.linalg.multi_dot dpnp.vdot @@ -46,15 +45,16 @@ Matrix eigenvalues dpnp.linalg.eigvals dpnp.linalg.eigvalsh -Norms etc. +Norms and other numbers ---------- .. autosummary:: :toctree: generated/ :nosignatures: - dpnp.linalg.det dpnp.linalg.norm + dpnp.linalg.cond + dpnp.linalg.det dpnp.linalg.matrix_rank dpnp.linalg.slogdet dpnp.trace @@ -73,14 +73,3 @@ Solving linear equations dpnp.linalg.inv dpnp.linalg.pinv dpnp.linalg.tensorinv - -Special Matrices ----------------- - -.. autosummary:: - :toctree: generated/ - :nosignatures: - - dpnp.tri - dpnp.tril - dpnp.triu diff --git a/doc/reference/manipulation.rst b/doc/reference/manipulation.rst index b36e8760185e..9d8dbd12842f 100644 --- a/doc/reference/manipulation.rst +++ b/doc/reference/manipulation.rst @@ -11,6 +11,7 @@ Basic operations :nosignatures: dpnp.copyto + dpnp.shape Changing array shape @@ -22,6 +23,8 @@ Changing array shape dpnp.reshape dpnp.ravel + dpnp.ndarray.flat + dpnp.ndarray.flatten Transpose-like operations @@ -34,10 +37,9 @@ Transpose-like operations dpnp.moveaxis dpnp.rollaxis dpnp.swapaxes + dpnp.ndarray.T dpnp.transpose -.. seealso:: - :attr:`dpnp.dparray.T` Changing number of dimensions ----------------------------- @@ -66,6 +68,7 @@ Changing kind of array dpnp.asarray dpnp.asnumpy dpnp.asanyarray + dpnp.asmatrix dpnp.asfarray dpnp.asfortranarray dpnp.ascontiguousarray @@ -81,10 +84,12 @@ Joining arrays dpnp.concatenate dpnp.stack + dpnp.block + dpnp.vstack + dpnp.hstack dpnp.column_stack + dpnp.row_stack dpnp.dstack - dpnp.hstack - dpnp.vstack Splitting arrays @@ -119,6 +124,10 @@ Adding and removing elements :toctree: generated/ :nosignatures: + dpnp.delete + dpnp.insert + dpnp.append + dpnp.resize dpnp.unique dpnp.trim_zeros diff --git a/doc/reference/math.rst b/doc/reference/math.rst index dee52ba710f8..0d75e08b7d8c 100644 --- a/doc/reference/math.rst +++ b/doc/reference/math.rst @@ -48,7 +48,7 @@ Rounding :nosignatures: dpnp.around - dpnp.round_ + dpnp.round dpnp.rint dpnp.fix dpnp.floor @@ -119,6 +119,17 @@ Floating point routines dpnp.frexp dpnp.ldexp dpnp.nextafter + dpnp.spacing + + +Rational routines +----------------- +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.lcm + dpnp.gcd Arithmetic operations @@ -131,12 +142,14 @@ Arithmetic operations dpnp.add dpnp.reciprocal dpnp.negative + dpnp.positive dpnp.multiply dpnp.divide dpnp.power dpnp.subtract dpnp.true_divide dpnp.floor_divide + dpnp.floor_power dpnp.fmod dpnp.mod dpnp.modf @@ -155,6 +168,26 @@ Handling complex numbers dpnp.real dpnp.imag dpnp.conj + dpnp.conjugate + + +Extrema Finding +--------------- + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.maximum + dpnp.max + dpnp.amax + dpnp.fmax + dpnp.nanmax + dpnp.minimum + dpnp.min + dpnp.amin + dpnp.fmin + dpnp.nanmin Miscellaneous @@ -173,10 +206,6 @@ Miscellaneous dpnp.absolute dpnp.fabs dpnp.sign - dpnp.maximum - dpnp.minimum - dpnp.fmax - dpnp.fmin dpnp.nan_to_num dpnp.bartlett dpnp.blackman diff --git a/doc/reference/misc.rst b/doc/reference/misc.rst index da3d17b8c025..413aace06ccf 100644 --- a/doc/reference/misc.rst +++ b/doc/reference/misc.rst @@ -11,3 +11,8 @@ Utility :nosignatures: dpnp.get_include + dpnp.show_config + dpnp.show_runtime + dpnp.deprecate + dpnp.deprecate_with_doc + dpnp.broadcast_shapes diff --git a/doc/reference/random.rst b/doc/reference/random.rst index 602483d14ba9..1a20e76bf7d8 100644 --- a/doc/reference/random.rst +++ b/doc/reference/random.rst @@ -3,7 +3,6 @@ Random Sampling (``dpnp.random``) ================================= -.. https://docs.scipy.org/doc/numpy-1.16.1/reference/routines.random.html .. https://docs.scipy.org/doc/numpy/reference/random/legacy.html diff --git a/doc/reference/routines.rst b/doc/reference/routines.rst index e920a6115343..4fd1f3a32ab6 100644 --- a/doc/reference/routines.rst +++ b/doc/reference/routines.rst @@ -13,7 +13,9 @@ These functions cover a subset of creation manipulation + indexing binary + dtype fft linalg logic diff --git a/doc/reference/sorting.rst b/doc/reference/sorting.rst index cd0ef99b9a72..170e0d33662a 100644 --- a/doc/reference/sorting.rst +++ b/doc/reference/sorting.rst @@ -37,6 +37,7 @@ Searching dpnp.where dpnp.argwhere dpnp.searchsorted + dpnp.extract Counting -------- diff --git a/doc/reference/statistics.rst b/doc/reference/statistics.rst index 2e1916759785..cdacffda29e4 100644 --- a/doc/reference/statistics.rst +++ b/doc/reference/statistics.rst @@ -1,7 +1,7 @@ Statistical Functions ===================== -.. https://docs.scipy.org/doc/scipy/reference/stats.html +.. https://docs.scipy.org/doc/numpy/reference/routines.statistics.html Order statistics ---------------- @@ -10,16 +10,14 @@ Order statistics :toctree: generated/ :nosignatures: - dpnp.amin - dpnp.amax - dpnp.min - dpnp.max - dpnp.nanmin - dpnp.nanmax + dpnp.ptp dpnp.percentile + dpnp.nanpercentile + dpnp.quantile + dpnp.nanquantile -Means and variances +Averages and variances ------------------- .. autosummary:: @@ -44,7 +42,11 @@ Histograms :nosignatures: dpnp.histogram + dpnp.histogram2d + dpnp.histogramdd dpnp.bincount + dpnp.histogram_bin_edges + dpnp.digitize Correlations diff --git a/doc/reference/ufunc.rst b/doc/reference/ufunc.rst index e2953bc45aa0..001f092a8ad7 100644 --- a/doc/reference/ufunc.rst +++ b/doc/reference/ufunc.rst @@ -120,9 +120,12 @@ Floating functions dpnp.isfinite dpnp.isinf dpnp.isnan + dpnp.isnat + dpnp.fabs dpnp.signbit dpnp.copysign dpnp.nextafter + dpnp.spacing dpnp.modf dpnp.ldexp dpnp.frexp From b3cd1d4d95bc0de562cc83fbd7f0994cdceb8038 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 19 Jul 2023 14:51:49 +0200 Subject: [PATCH 2/9] Refresh Multi-Dimensional Array section --- doc/reference/creation.rst | 2 + doc/reference/dtype.rst | 2 + doc/reference/indexing.rst | 2 + doc/reference/ndarray.rst | 349 +++++++++++++++++++++++++++++++++++++ doc/reference/ufunc.rst | 2 + 5 files changed, 357 insertions(+) diff --git a/doc/reference/creation.rst b/doc/reference/creation.rst index 0ab30d2e9a28..c898b628fe6c 100644 --- a/doc/reference/creation.rst +++ b/doc/reference/creation.rst @@ -1,3 +1,5 @@ +.. _routines.creation: + Array Creation Routines ======================= diff --git a/doc/reference/dtype.rst b/doc/reference/dtype.rst index 7dbc491fdcd4..29607c52fc8a 100644 --- a/doc/reference/dtype.rst +++ b/doc/reference/dtype.rst @@ -1,3 +1,5 @@ +.. _dtype: + Data type routines ================== diff --git a/doc/reference/indexing.rst b/doc/reference/indexing.rst index 0cc64b995dec..6b77133dbe6a 100644 --- a/doc/reference/indexing.rst +++ b/doc/reference/indexing.rst @@ -1,3 +1,5 @@ +.. _routines.indexing: + Array Indexing Routines ======================= diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index 5fca216ec94c..2232578a5be6 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -12,3 +12,352 @@ For the basic concept of ``ndarray``\s, please refer to the `NumPy documentation dpnp.ndarray dpnp.dpnp_array.dpnp_array + + +Constructing arrays +=================== + +New arrays can be constructed using the routines detailed in +:ref:`Array Creation Routines `, and also by using the low-level +:class:`dpnp.ndarray` constructor: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray + + +Indexing arrays +=============== + +Arrays can be indexed using an extended Python slicing syntax, +``array[selection]``. Similar syntax is also used for accessing +fields in a :term:`structured data type`. + +.. seealso:: :ref:`Array Indexing Routines `. + + +Array attributes +================ + +Array attributes reflect information that is intrinsic to the array +itself. Generally, accessing an array through its attributes allows +you to get and sometimes set intrinsic properties of the array without +creating a new array. The exposed attributes are the core parts of an +array and only some of them can be reset meaningfully without creating +a new array. Information on each attribute is given below. + + +Memory layout +------------- + +The following attributes contain information about the memory layout +of the array: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.flags + dpnp.ndarray.shape + dpnp.ndarray.strides + dpnp.ndarray.ndim + dpnp.ndarray.data + dpnp.ndarray.size + dpnp.ndarray.itemsize + dpnp.ndarray.nbytes + dpnp.ndarray.base + + +Data type +--------- + +.. seealso:: :ref:`Data type objects ` + +The data type object associated with the array can be found in the +:attr:`dtype ` attribute: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.dtype + + +Other attributes +---------------- + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.T + dpnp.ndarray.real + dpnp.ndarray.imag + dpnp.ndarray.flat + + +Array methods +============= + +An :class:`dpnp.ndarray` object has many methods which operate on or with +the array in some fashion, typically returning an array result. These +methods are briefly explained below. (Each method's docstring has a +more complete description.) + +For the following methods there are also corresponding functions in +:mod:`dpnp`: :func:`all `, :func:`any `, +:func:`argmax `, :func:`argmin `, +:func:`argpartition `, :func:`argsort `, +:func:`choose `, :func:`clip `, +:func:`compress `, :func:`copy `, +:func:`cumprod `, :func:`cumsum `, +:func:`diagonal `, :func:`imag `, +:func:`max `, :func:`mean `, :func:`min `, +:func:`nonzero `, :func:`partition `, +:func:`prod `, :func:`ptp `, :func:`put `, +:func:`ravel `, :func:`real `, :func:`repeat `, +:func:`reshape `, :func:`round `, +:func:`searchsorted `, :func:`sort `, +:func:`squeeze `, :func:`std `, :func:`sum `, +:func:`swapaxes `, :func:`take `, :func:`trace `, +:func:`transpose `, :func:`var `. + + +Array conversion +---------------- + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.item + dpnp.ndarray.tolist + dpnp.ndarray.itemset + dpnp.ndarray.tostring + dpnp.ndarray.tobytes + dpnp.ndarray.tofile + dpnp.ndarray.dump + dpnp.ndarray.dumps + dpnp.ndarray.astype + dpnp.ndarray.byteswap + dpnp.ndarray.copy + dpnp.ndarray.view + dpnp.ndarray.getfield + dpnp.ndarray.setflags + dpnp.ndarray.fill + + +Shape manipulation +------------------ + +For reshape, resize, and transpose, the single tuple argument may be +replaced with ``n`` integers which will be interpreted as an n-tuple. + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.reshape + dpnp.ndarray.resize + dpnp.ndarray.transpose + dpnp.ndarray.swapaxes + dpnp.ndarray.flatten + dpnp.ndarray.ravel + dpnp.ndarray.squeeze + + +Item selection and manipulation +------------------------------- + +For array methods that take an *axis* keyword, it defaults to +*None*. If axis is *None*, then the array is treated as a 1-D +array. Any other value for *axis* represents the dimension along which +the operation should proceed. + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.take + dpnp.ndarray.put + dpnp.ndarray.repeat + dpnp.ndarray.choose + dpnp.ndarray.sort + dpnp.ndarray.argsort + dpnp.ndarray.partition + dpnp.ndarray.argpartition + dpnp.ndarray.searchsorted + dpnp.ndarray.nonzero + dpnp.ndarray.compress + dpnp.ndarray.diagonal + + +Calculation +----------- + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.max + dpnp.ndarray.argmax + dpnp.ndarray.min + dpnp.ndarray.argmin + dpnp.ndarray.ptp + dpnp.ndarray.clip + dpnp.ndarray.conj + dpnp.ndarray.conjugate + dpnp.ndarray.round + dpnp.ndarray.trace + dpnp.ndarray.sum + dpnp.ndarray.cumsum + dpnp.ndarray.mean + dpnp.ndarray.var + dpnp.ndarray.std + dpnp.ndarray.prod + dpnp.ndarray.cumprod + dpnp.ndarray.all + dpnp.ndarray.any + + +Arithmetic, matrix multiplication, and comparison operations +============================================================ + +Arithmetic and comparison operations on :class:`dpnp.ndarrays ` +are defined as element-wise operations, and generally yield +:class:`dpnp.ndarray` objects as results. + +Each of the arithmetic operations (``+``, ``-``, ``*``, ``/``, ``//``, +``%``, ``divmod()``, ``**`` or ``pow()``, ``<<``, ``>>``, ``&``, +``^``, ``|``, ``~``) and the comparisons (``==``, ``<``, ``>``, +``<=``, ``>=``, ``!=``) is equivalent to the corresponding +universal function (or **ufunc** for short) in DPNP. For +more information, see the section on :ref:`Universal Functions +`. + + +Comparison operators: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__lt__ + dpnp.ndarray.__le__ + dpnp.ndarray.__gt__ + dpnp.ndarray.__ge__ + dpnp.ndarray.__eq__ + dpnp.ndarray.__ne__ + + +Unary operations: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__neg__ + dpnp.ndarray.__pos__ + dpnp.ndarray.__abs__ + dpnp.ndarray.__invert__ + + +Arithmetic: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__add__ + dpnp.ndarray.__sub__ + dpnp.ndarray.__mul__ + dpnp.ndarray.__truediv__ + dpnp.ndarray.__floordiv__ + dpnp.ndarray.__mod__ + dpnp.ndarray.__divmod__ + dpnp.ndarray.__pow__ + dpnp.ndarray.__lshift__ + dpnp.ndarray.__rshift__ + dpnp.ndarray.__and__ + dpnp.ndarray.__or__ + dpnp.ndarray.__xor__ + + +Arithmetic, in-place: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__iadd__ + dpnp.ndarray.__isub__ + dpnp.ndarray.__imul__ + dpnp.ndarray.__itruediv__ + dpnp.ndarray.__ifloordiv__ + dpnp.ndarray.__imod__ + dpnp.ndarray.__ipow__ + dpnp.ndarray.__ilshift__ + dpnp.ndarray.__irshift__ + dpnp.ndarray.__iand__ + dpnp.ndarray.__ior__ + dpnp.ndarray.__ixor__ + + +Special methods +=============== + +For standard library functions: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__copy__ + dpnp.ndarray.__deepcopy__ + dpnp.ndarray.__reduce__ + dpnp.ndarray.__setstate__ + +Basic customization: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__new__ + dpnp.ndarray.__array__ + dpnp.ndarray.__array_wrap__ + +Container customization: (see :ref:`Indexing `) + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__len__ + dpnp.ndarray.__getitem__ + dpnp.ndarray.__setitem__ + dpnp.ndarray.__contains__ + +Conversion; the operations :class:`int() `, +:class:`float() ` and :class:`complex() `. +They work only on arrays that have one element in them +and return the appropriate scalar. + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__int__ + dpnp.ndarray.__float__ + dpnp.ndarray.__complex__ + +String representations: + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + dpnp.ndarray.__str__ + dpnp.ndarray.__repr__ diff --git a/doc/reference/ufunc.rst b/doc/reference/ufunc.rst index 001f092a8ad7..4e74ac78ca3e 100644 --- a/doc/reference/ufunc.rst +++ b/doc/reference/ufunc.rst @@ -1,3 +1,5 @@ +.. _ufunc: + Universal Functions (ufunc) =========================== From b146475bc2e73add58dea4377dc6ad70f7367107 Mon Sep 17 00:00:00 2001 From: vlad-perevezentsev Date: Thu, 20 Jul 2023 23:35:39 +0200 Subject: [PATCH 3/9] Pin to numpy<1.24 in build_sphinx (#1491) --- .github/workflows/build-sphinx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-sphinx.yml b/.github/workflows/build-sphinx.yml index f58021db1351..02118c5d1597 100644 --- a/.github/workflows/build-sphinx.yml +++ b/.github/workflows/build-sphinx.yml @@ -79,7 +79,7 @@ jobs: - name: Install dpnp dependencies run: | - conda install dpctl mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ + conda install numpy"<1.24" dpctl mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ cmake cython"<3" pytest ninja scikit-build sysroot_linux-64">=2.28" ${{ env.CHANNELS }} - name: Install cuPy dependencies From 88f6d9bf945981c4dc85c1a68872bf72fdae1f44 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 2 Aug 2023 11:18:44 +0200 Subject: [PATCH 4/9] Make subchapters for ndarray chapter --- doc/reference/ndarray.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index 2232578a5be6..912115abd295 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -15,7 +15,7 @@ For the basic concept of ``ndarray``\s, please refer to the `NumPy documentation Constructing arrays -=================== +------------------- New arrays can be constructed using the routines detailed in :ref:`Array Creation Routines `, and also by using the low-level @@ -29,7 +29,7 @@ New arrays can be constructed using the routines detailed in Indexing arrays -=============== +--------------- Arrays can be indexed using an extended Python slicing syntax, ``array[selection]``. Similar syntax is also used for accessing @@ -39,7 +39,7 @@ fields in a :term:`structured data type`. Array attributes -================ +---------------- Array attributes reflect information that is intrinsic to the array itself. Generally, accessing an array through its attributes allows @@ -99,7 +99,7 @@ Other attributes Array methods -============= +------------- An :class:`dpnp.ndarray` object has many methods which operate on or with the array in some fashion, typically returning an array result. These @@ -223,7 +223,7 @@ Calculation Arithmetic, matrix multiplication, and comparison operations -============================================================ +------------------------------------------------------------ Arithmetic and comparison operations on :class:`dpnp.ndarrays ` are defined as element-wise operations, and generally yield @@ -306,7 +306,7 @@ Arithmetic, in-place: Special methods -=============== +--------------- For standard library functions: From a79ae8353ace3a03e168e70d38e8f70298392e97 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 2 Aug 2023 14:17:12 +0200 Subject: [PATCH 5/9] Rename Difference with NumPy chapter --- doc/reference/difference.rst | 46 +++++++++++++++++++++++++++++++++--- doc/reference/ndarray.rst | 2 +- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/doc/reference/difference.rst b/doc/reference/difference.rst index 9f2d28f3b971..49194ecdbcce 100644 --- a/doc/reference/difference.rst +++ b/doc/reference/difference.rst @@ -1,5 +1,5 @@ -Difference with NumPy* -====================== +Available array data types +========================== .. _Data types: @@ -7,4 +7,44 @@ Data types ---------- Data types (dtypes) of DPNP arrays are limited by the following types: -``bool``, ``complex128``, ``float32``, ``float64``, ``int32``, ``int64``, ``nan`` + +- :obj:`bool ` +- :obj:`bool_ ` +- :obj:`cdouble ` +- :obj:`complex ` +- :obj:`complex128 ` +- :obj:`complex64 ` +- :obj:`cfloat ` +- :obj:`csingle ` +- :obj:`double ` +- :obj:`float ` +- :obj:`float_ ` +- :obj:`float16 ` +- :obj:`float32 ` +- :obj:`float64 ` +- :obj:`int ` +- :obj:`int_ ` +- :obj:`int32 ` +- :obj:`int64 ` +- :obj:`intc ` +- :obj:`single ` +- :obj:`singlecomplex ` + + +Constants +--------- + +- :obj:`e ` +- :obj:`euler_gamma ` +- :obj:`Inf ` +- :obj:`inf ` +- :obj:`Infinity ` +- :obj:`infty ` +- :obj:`NAN ` +- :obj:`NaN ` +- :obj:`nan ` +- :obj:`NINF ` +- :obj:`NZERO ` +- :obj:`pi ` +- :obj:`PINF ` +- :obj:`PZERO ` diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index 912115abd295..4fe15f17880a 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -73,7 +73,7 @@ of the array: Data type --------- -.. seealso:: :ref:`Data type objects ` +.. seealso:: :ref:`Available array data types ` The data type object associated with the array can be found in the :attr:`dtype ` attribute: From 2ae422098fb9b48e8773d5b0c7ab9c6245cd328e Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 10 Aug 2023 23:42:40 +0200 Subject: [PATCH 6/9] Update Available array data types chapter --- doc/reference/difference.rst | 50 ---------------------------------- doc/reference/dtypes_table.rst | 50 ++++++++++++++++++++++++++++++++++ doc/reference/index.rst | 2 +- 3 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 doc/reference/difference.rst create mode 100644 doc/reference/dtypes_table.rst diff --git a/doc/reference/difference.rst b/doc/reference/difference.rst deleted file mode 100644 index 49194ecdbcce..000000000000 --- a/doc/reference/difference.rst +++ /dev/null @@ -1,50 +0,0 @@ -Available array data types -========================== - -.. _Data types: - -Data types ----------- - -Data types (dtypes) of DPNP arrays are limited by the following types: - -- :obj:`bool ` -- :obj:`bool_ ` -- :obj:`cdouble ` -- :obj:`complex ` -- :obj:`complex128 ` -- :obj:`complex64 ` -- :obj:`cfloat ` -- :obj:`csingle ` -- :obj:`double ` -- :obj:`float ` -- :obj:`float_ ` -- :obj:`float16 ` -- :obj:`float32 ` -- :obj:`float64 ` -- :obj:`int ` -- :obj:`int_ ` -- :obj:`int32 ` -- :obj:`int64 ` -- :obj:`intc ` -- :obj:`single ` -- :obj:`singlecomplex ` - - -Constants ---------- - -- :obj:`e ` -- :obj:`euler_gamma ` -- :obj:`Inf ` -- :obj:`inf ` -- :obj:`Infinity ` -- :obj:`infty ` -- :obj:`NAN ` -- :obj:`NaN ` -- :obj:`nan ` -- :obj:`NINF ` -- :obj:`NZERO ` -- :obj:`pi ` -- :obj:`PINF ` -- :obj:`PZERO ` diff --git a/doc/reference/dtypes_table.rst b/doc/reference/dtypes_table.rst new file mode 100644 index 000000000000..879cf8b59cd1 --- /dev/null +++ b/doc/reference/dtypes_table.rst @@ -0,0 +1,50 @@ +Available array data types +========================== + +.. _Data types: + + +Table below shows a list of all supported data types (dtypes) and constants of the Data Parallel Extension for NumPy*. + +.. list-table:: + :header-rows: 1 + + * - Data Types + - Type aliases + - Constants + * - + - :obj:`bool ` + - :obj:`int32 ` + - :obj:`int64 ` + - :obj:`complex64 ` + - :obj:`complex128 ` + - + - :obj:`bool_ ` + - :obj:`cdouble ` + - :obj:`complex ` + - :obj:`cfloat ` + - :obj:`csingle ` + - :obj:`double ` + - :obj:`float ` + - :obj:`float_ ` + - :obj:`float16 ` + - :obj:`int ` + - :obj:`int_ ` + - :obj:`intc ` + - :obj:`single ` + - :obj:`singlecomplex ` + - + - :obj:`e ` + - :obj:`euler_gamma ` + - :obj:`Inf ` + - :obj:`inf ` + - :obj:`Infinity ` + - :obj:`infty ` + - :obj:`NAN ` + - :obj:`NaN ` + - :obj:`nan ` + - :obj:`NINF ` + - :obj:`NZERO ` + - :obj:`pi ` + - :obj:`PINF ` + - :obj:`PZERO ` diff --git a/doc/reference/index.rst b/doc/reference/index.rst index 2885ac86df3e..44a29008871c 100644 --- a/doc/reference/index.rst +++ b/doc/reference/index.rst @@ -30,6 +30,6 @@ API reference of the Data Parallel Extension for NumPy* testing prof environment - difference + dtypes_table comparison misc From e75a69aa18761225ef4eff9fee6df1ee82302ddf Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 11 Aug 2023 14:54:14 +0200 Subject: [PATCH 7/9] Delete structured data types line --- doc/reference/ndarray.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index 4fe15f17880a..a180c0a755dc 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -32,8 +32,7 @@ Indexing arrays --------------- Arrays can be indexed using an extended Python slicing syntax, -``array[selection]``. Similar syntax is also used for accessing -fields in a :term:`structured data type`. +``array[selection]``. .. seealso:: :ref:`Array Indexing Routines `. From ddc913f527b26a09fd75f17f3984f41535f86f89 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 11 Aug 2023 20:30:37 +0200 Subject: [PATCH 8/9] Add missing docstrings --- dpnp/dpnp_array.py | 30 +++++++++++++++++++++++++++++- dpnp/dpnp_flatiter.py | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 17957e154044..8b2a8c90716a 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -138,12 +138,15 @@ def usm_type(self): return self._array_obj.usm_type def __abs__(self): + r"""Return \|self\|.""" return dpnp.abs(self) def __add__(self, other): + """Return self+value.""" return dpnp.add(self, other) def __and__(self, other): + """Return self&value.""" return dpnp.bitwise_and(self, other) # '__array__', @@ -194,6 +197,7 @@ def __ge__(self, other): # '__getattribute__', def __getitem__(self, key): + """Return self[key].""" key = _get_unwrapped_index_key(key) item = self._array_obj.__getitem__(key) @@ -214,16 +218,19 @@ def __gt__(self, other): # '__hash__', def __iadd__(self, other): + """Return self+=value.""" dpnp.add(self, other, out=self) return self def __iand__(self, other): + """Return self&=value.""" dpnp.bitwise_and(self, other, out=self) return self # '__ifloordiv__', def __ilshift__(self, other): + """Return self<<=value.""" dpnp.left_shift(self, other, out=self) return self @@ -231,6 +238,7 @@ def __ilshift__(self, other): # '__imod__', def __imul__(self, other): + """Return self*=value.""" dpnp.multiply(self, other, out=self) return self @@ -244,31 +252,38 @@ def __int__(self): return self._array_obj.__int__() def __invert__(self): + """Return ~self.""" return dpnp.invert(self) def __ior__(self, other): + """Return self|=value.""" dpnp.bitwise_or(self, other, out=self) return self def __ipow__(self, other): + """Return self**=value.""" dpnp.power(self, other, out=self) return self def __irshift__(self, other): + """Return self>>=value.""" dpnp.right_shift(self, other, out=self) return self def __isub__(self, other): + """Return self-=value.""" dpnp.subtract(self, other, out=self) return self # '__iter__', def __itruediv__(self, other): + """Return self/=value.""" dpnp.true_divide(self, other, out=self) return self def __ixor__(self, other): + """Return self^=value.""" dpnp.bitwise_xor(self, other, out=self) return self @@ -276,11 +291,12 @@ def __le__(self, other): return dpnp.less_equal(self, other) def __len__(self): - """Performs the operation __len__.""" + """Return len(self).""" return self._array_obj.__len__() def __lshift__(self, other): + """Return self<>value.""" return dpnp.right_shift(self, other) def __rsub__(self, other): @@ -362,6 +384,7 @@ def __rxor__(self, other): # '__setattr__', def __setitem__(self, key, val): + """Set self[key] to value.""" key = _get_unwrapped_index_key(key) if isinstance(val, dpnp_array): @@ -388,14 +411,17 @@ def __str__(self): return self._array_obj.__str__() def __sub__(self, other): + """Return self-value.""" return dpnp.subtract(self, other) # '__subclasshook__', def __truediv__(self, other): + """Return self/value.""" return dpnp.true_divide(self, other) def __xor__(self, other): + """Return self^value.""" return dpnp.bitwise_xor(self, other) @staticmethod @@ -823,6 +849,8 @@ def ndim(self): # 'newbyteorder', def nonzero(self): + """Return the indices of the elements that are non-zero.""" + return dpnp.nonzero(self) def partition(self, kth, axis=-1, kind="introselect", order=None): diff --git a/dpnp/dpnp_flatiter.py b/dpnp/dpnp_flatiter.py index 4370d1e09eb2..00e6ec447701 100644 --- a/dpnp/dpnp_flatiter.py +++ b/dpnp/dpnp_flatiter.py @@ -30,6 +30,8 @@ class flatiter: + """Flat iterator object to iterate over arrays.""" + def __init__(self, X): if type(X) is not dpnp.ndarray: raise TypeError( From 30b4b80894fe5314f6e6d3d4e8e57eb3c9de038f Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 11 Aug 2023 20:34:37 +0200 Subject: [PATCH 9/9] Hide empty subchapter of routines --- doc/reference/ndarray.rst | 2 +- doc/reference/routines.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index a180c0a755dc..3ebfeb96028a 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -315,7 +315,7 @@ For standard library functions: dpnp.ndarray.__copy__ dpnp.ndarray.__deepcopy__ - dpnp.ndarray.__reduce__ + .. dpnp.ndarray.__reduce__ dpnp.ndarray.__setstate__ Basic customization: diff --git a/doc/reference/routines.rst b/doc/reference/routines.rst index 4fd1f3a32ab6..645d1a6be5d2 100644 --- a/doc/reference/routines.rst +++ b/doc/reference/routines.rst @@ -20,8 +20,8 @@ These functions cover a subset of linalg logic math - pad - polynomials + .. pad + .. polynomials random sorting statistics