Skip to content

Commit 1b8823b

Browse files
Align signature of dpnp.astype with Python array API (#2318)
The PR is aimed to align signature of `dpnp.astype` function with Python array API where only `x` and `dtype` arguments are positional-only and other arguments are keyword-only. Also docstrings of `dpnp.astype` function and `dpnp.ndarray,astype` method are aligned and properly updated. And `dpnp.astype` function is moved to array creation namespace like NumPy has it. Additionally, docstring of `device` keyword is updated and aligned across all the functions description to have it described in a common way. af0fc93
1 parent 3e1360b commit 1b8823b

File tree

1,049 files changed

+2507
-2311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,049 files changed

+2507
-2311
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 20d206a136d06d5dbb282a257089c551
3+
config: a16914242e9d4b5202847ce7178b6ed2
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_modules/dpnp/dpnp_array.html

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
</script>
1515

1616
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
17-
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev6+20.gf56a43f4892 documentation</title>
17+
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev7+3.gaf0fc93fad5 documentation</title>
1818
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
1919
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
2020

2121

2222
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2323
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
24-
<script src="../../_static/documentation_options.js?v=dbee7e7a"></script>
24+
<script src="../../_static/documentation_options.js?v=7237ab0c"></script>
2525
<script src="../../_static/doctools.js?v=9bcbadda"></script>
2626
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2727
<script src="../../_static/js/theme.js"></script>
@@ -899,47 +899,51 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
899899

900900
<span class="sd"> Parameters</span>
901901
<span class="sd"> ----------</span>
902-
<span class="sd"> x1 : {dpnp.ndarray, usm_ndarray}</span>
903-
<span class="sd"> Array data type casting.</span>
904902
<span class="sd"> dtype : {None, str, dtype object}</span>
905903
<span class="sd"> Target data type.</span>
906-
<span class="sd"> order : {&quot;C&quot;, &quot;F&quot;, &quot;A&quot;, &quot;K&quot;}, optional</span>
904+
<span class="sd"> order : {None, &quot;C&quot;, &quot;F&quot;, &quot;A&quot;, &quot;K&quot;}, optional</span>
907905
<span class="sd"> Row-major (C-style) or column-major (Fortran-style) order.</span>
908-
<span class="sd"> When ``order`` is &#39;A&#39;, it uses &#39;F&#39; if ``a`` is column-major and uses &#39;C&#39; otherwise.</span>
909-
<span class="sd"> And when ``order`` is &#39;K&#39;, it keeps strides as closely as possible.</span>
910-
<span class="sd"> copy : bool</span>
911-
<span class="sd"> If it is False and no cast happens, then this method returns the array itself.</span>
912-
<span class="sd"> Otherwise, a copy is returned.</span>
913-
<span class="sd"> casting : {&#39;no&#39;, &#39;equiv&#39;, &#39;safe&#39;, &#39;same_kind&#39;, &#39;unsafe&#39;}, optional</span>
914-
<span class="sd"> Controls what kind of data casting may occur.</span>
915-
<span class="sd"> Defaults to ``&#39;unsafe&#39;`` for backwards compatibility.</span>
916-
917-
<span class="sd"> - &#39;no&#39; means the data types should not be cast at all.</span>
918-
<span class="sd"> - &#39;equiv&#39; means only byte-order changes are allowed.</span>
919-
<span class="sd"> - &#39;safe&#39; means only casts which can preserve values are allowed.</span>
920-
<span class="sd"> - &#39;same_kind&#39; means only safe casts or casts within a kind, like</span>
921-
<span class="sd"> float64 to float32, are allowed.</span>
922-
<span class="sd"> - &#39;unsafe&#39; means any data conversions may be done.</span>
923-
924-
<span class="sd"> copy : {bool}, optional</span>
925-
<span class="sd"> By default, ``astype`` always returns a newly allocated array. If</span>
926-
<span class="sd"> this is set to ``False``, and the `dtype`, `order`, and `subok`</span>
927-
<span class="sd"> requirements are satisfied, the input array is returned instead of</span>
928-
<span class="sd"> a copy.</span>
929-
<span class="sd"> device : {None, string, SyclDevice, SyclQueue}, optional</span>
906+
<span class="sd"> When `order` is ``&quot;A&quot;``, it uses ``&quot;F&quot;`` if `a` is column-major and</span>
907+
<span class="sd"> uses ``&quot;C&quot;`` otherwise. And when `order` is ``&quot;K&quot;``, it keeps</span>
908+
<span class="sd"> strides as closely as possible.</span>
909+
910+
<span class="sd"> Default: ``&quot;K&quot;``.</span>
911+
<span class="sd"> casting : {&quot;no&quot;, &quot;equiv&quot;, &quot;safe&quot;, &quot;same_kind&quot;, &quot;unsafe&quot;}, optional</span>
912+
<span class="sd"> Controls what kind of data casting may occur. Defaults to</span>
913+
<span class="sd"> ``&quot;unsafe&quot;`` for backwards compatibility.</span>
914+
915+
<span class="sd"> - &quot;no&quot; means the data types should not be cast at all.</span>
916+
<span class="sd"> - &quot;equiv&quot; means only byte-order changes are allowed.</span>
917+
<span class="sd"> - &quot;safe&quot; means only casts which can preserve values are allowed.</span>
918+
<span class="sd"> - &quot;same_kind&quot; means only safe casts or casts within a kind,</span>
919+
<span class="sd"> like float64 to float32, are allowed.</span>
920+
<span class="sd"> - &quot;unsafe&quot; means any data conversions may be done.</span>
921+
922+
<span class="sd"> Default: ``&quot;unsafe&quot;``.</span>
923+
<span class="sd"> copy : bool, optional</span>
924+
<span class="sd"> Specifies whether to copy an array when the specified dtype matches</span>
925+
<span class="sd"> the data type of that array. If ``True``, a newly allocated array</span>
926+
<span class="sd"> must always be returned. If ``False`` and the specified dtype</span>
927+
<span class="sd"> matches the data type of that array, the self array must be returned;</span>
928+
<span class="sd"> otherwise, a newly allocated array must be returned.</span>
929+
930+
<span class="sd"> Default: ``True``.</span>
931+
<span class="sd"> device : {None, string, SyclDevice, SyclQueue, Device}, optional</span>
930932
<span class="sd"> An array API concept of device where the output array is created.</span>
931-
<span class="sd"> The `device` can be ``None`` (the default), an OneAPI filter selector</span>
932-
<span class="sd"> string, an instance of :class:`dpctl.SyclDevice` corresponding to</span>
933-
<span class="sd"> a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,</span>
934-
<span class="sd"> or a `Device` object returned by</span>
935-
<span class="sd"> :obj:`dpnp.dpnp_array.dpnp_array.device` property. Default: ``None``.</span>
933+
<span class="sd"> `device` can be ``None``, a oneAPI filter selector string,</span>
934+
<span class="sd"> an instance of :class:`dpctl.SyclDevice` corresponding to</span>
935+
<span class="sd"> a non-partitioned SYCL device, an instance of</span>
936+
<span class="sd"> :class:`dpctl.SyclQueue`, or a :class:`dpctl.tensor.Device` object</span>
937+
<span class="sd"> returned by :attr:`dpnp.ndarray.device`.</span>
938+
<span class="sd"> If the value is ``None``, returned array is created on the same</span>
939+
<span class="sd"> device as that array.</span>
940+
941+
<span class="sd"> Default: ``None``.</span>
936942

937943
<span class="sd"> Returns</span>
938944
<span class="sd"> -------</span>
939-
<span class="sd"> arr_t : dpnp.ndarray</span>
940-
<span class="sd"> Unless `copy` is ``False`` and the other conditions for returning the input array</span>
941-
<span class="sd"> are satisfied, `arr_t` is a new array of the same shape as the input array,</span>
942-
<span class="sd"> with dtype, order given by dtype, order.</span>
945+
<span class="sd"> out : dpnp.ndarray</span>
946+
<span class="sd"> An array having the specified data type.</span>
943947

944948
<span class="sd"> Limitations</span>
945949
<span class="sd"> -----------</span>
@@ -949,9 +953,9 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
949953
<span class="sd"> Examples</span>
950954
<span class="sd"> --------</span>
951955
<span class="sd"> &gt;&gt;&gt; import dpnp as np</span>
952-
<span class="sd"> &gt;&gt;&gt; x = np.array([1, 2, 2.5])</span>
953-
<span class="sd"> &gt;&gt;&gt; x</span>
956+
<span class="sd"> &gt;&gt;&gt; x = np.array([1, 2, 2.5]); x</span>
954957
<span class="sd"> array([1. , 2. , 2.5])</span>
958+
955959
<span class="sd"> &gt;&gt;&gt; x.astype(int)</span>
956960
<span class="sd"> array([1, 2, 2])</span>
957961

@@ -1053,13 +1057,14 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
10531057
<span class="sd"> order : {&quot;C&quot;, &quot;F&quot;, &quot;A&quot;, &quot;K&quot;}, optional</span>
10541058
<span class="sd"> Memory layout of the newly output array.</span>
10551059
<span class="sd"> Default: ``&quot;C&quot;``.</span>
1056-
<span class="sd"> device : {None, string, SyclDevice, SyclQueue}, optional</span>
1060+
<span class="sd"> device : {None, string, SyclDevice, SyclQueue, Device}, optional</span>
10571061
<span class="sd"> An array API concept of device where the output array is created.</span>
1058-
<span class="sd"> The `device` can be ``None`` (the default), an OneAPI filter</span>
1059-
<span class="sd"> selector string, an instance of :class:`dpctl.SyclDevice`</span>
1060-
<span class="sd"> corresponding to a non-partitioned SYCL device, an instance of</span>
1061-
<span class="sd"> :class:`dpctl.SyclQueue`, or a `Device` object returned by</span>
1062-
<span class="sd"> :obj:`dpnp.dpnp_array.dpnp_array.device` property.</span>
1062+
<span class="sd"> `device` can be ``None``, a oneAPI filter selector string,</span>
1063+
<span class="sd"> an instance of :class:`dpctl.SyclDevice` corresponding to</span>
1064+
<span class="sd"> a non-partitioned SYCL device, an instance of</span>
1065+
<span class="sd"> :class:`dpctl.SyclQueue`, or a :class:`dpctl.tensor.Device` object</span>
1066+
<span class="sd"> returned by :attr:`dpnp.ndarray.device`.</span>
1067+
10631068
<span class="sd"> Default: ``None``.</span>
10641069
<span class="sd"> usm_type : {None, &quot;device&quot;, &quot;shared&quot;, &quot;host&quot;}, optional</span>
10651070
<span class="sd"> The type of SYCL USM allocation for the output array.</span>
@@ -2027,12 +2032,13 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
20272032

20282033
<span class="sd"> Parameters</span>
20292034
<span class="sd"> ----------</span>
2030-
<span class="sd"> device : {string, SyclDevice, SyclQueue}</span>
2031-
<span class="sd"> Array API concept of target device. It can be an OneAPI filter</span>
2032-
<span class="sd"> selector string, an instance of :class:`dpctl.SyclDevice`</span>
2033-
<span class="sd"> corresponding to a non-partitioned SYCL device, an instance of</span>
2035+
<span class="sd"> device : {None, string, SyclDevice, SyclQueue, Device}, optional</span>
2036+
<span class="sd"> An array API concept of device where the output array is created.</span>
2037+
<span class="sd"> `device` can be ``None``, a oneAPI filter selector string,</span>
2038+
<span class="sd"> an instance of :class:`dpctl.SyclDevice` corresponding to</span>
2039+
<span class="sd"> a non-partitioned SYCL device, an instance of</span>
20342040
<span class="sd"> :class:`dpctl.SyclQueue`, or a :class:`dpctl.tensor.Device` object</span>
2035-
<span class="sd"> returned by :obj:`dpnp.dpnp_array.dpnp_array.device` property.</span>
2041+
<span class="sd"> returned by :attr:`dpnp.ndarray.device`.</span>
20362042
<span class="sd"> stream : {SyclQueue, None}, optional</span>
20372043
<span class="sd"> Execution queue to synchronize with. If ``None``, synchronization</span>
20382044
<span class="sd"> is not performed.</span>

_modules/dpnp/fft/dpnp_iface_fft.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
</script>
1515

1616
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
17-
<title>dpnp.fft.dpnp_iface_fft &mdash; Data Parallel Extension for NumPy 0.17.0dev6+20.gf56a43f4892 documentation</title>
17+
<title>dpnp.fft.dpnp_iface_fft &mdash; Data Parallel Extension for NumPy 0.17.0dev7+3.gaf0fc93fad5 documentation</title>
1818
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=03e43079" />
1919
<link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=e59714d7" />
2020

2121

2222
<script src="../../../_static/jquery.js?v=5d32c60e"></script>
2323
<script src="../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
24-
<script src="../../../_static/documentation_options.js?v=dbee7e7a"></script>
24+
<script src="../../../_static/documentation_options.js?v=7237ab0c"></script>
2525
<script src="../../../_static/doctools.js?v=9bcbadda"></script>
2626
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
2727
<script src="../../../_static/js/theme.js"></script>
@@ -372,13 +372,14 @@ <h1>Source code for dpnp.fft.dpnp_iface_fft</h1><div class="highlight"><pre>
372372
<span class="sd"> d : scalar, optional</span>
373373
<span class="sd"> Sample spacing (inverse of the sampling rate).</span>
374374
<span class="sd"> Default: ``1.0``.</span>
375-
<span class="sd"> device : {None, string, SyclDevice, SyclQueue}, optional</span>
375+
<span class="sd"> device : {None, string, SyclDevice, SyclQueue, Device}, optional</span>
376376
<span class="sd"> An array API concept of device where the output array is created.</span>
377-
<span class="sd"> The `device` can be ``None`` (the default), an OneAPI filter selector</span>
378-
<span class="sd"> string, an instance of :class:`dpctl.SyclDevice` corresponding to</span>
379-
<span class="sd"> a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,</span>
380-
<span class="sd"> or a `Device` object returned by</span>
381-
<span class="sd"> :obj:`dpnp.dpnp_array.dpnp_array.device` property.</span>
377+
<span class="sd"> `device` can be ``None``, a oneAPI filter selector string, an instance</span>
378+
<span class="sd"> of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL</span>
379+
<span class="sd"> device, an instance of :class:`dpctl.SyclQueue`, or a</span>
380+
<span class="sd"> :class:`dpctl.tensor.Device` object returned by</span>
381+
<span class="sd"> :attr:`dpnp.ndarray.device`.</span>
382+
382383
<span class="sd"> Default: ``None``.</span>
383384
<span class="sd"> usm_type : {None, &quot;device&quot;, &quot;shared&quot;, &quot;host&quot;}, optional</span>
384385
<span class="sd"> The type of SYCL USM allocation for the output array.</span>
@@ -1677,13 +1678,14 @@ <h1>Source code for dpnp.fft.dpnp_iface_fft</h1><div class="highlight"><pre>
16771678
<span class="sd"> d : scalar, optional</span>
16781679
<span class="sd"> Sample spacing (inverse of the sampling rate).</span>
16791680
<span class="sd"> Default: ``1.0``.</span>
1680-
<span class="sd"> device : {None, string, SyclDevice, SyclQueue}, optional</span>
1681+
<span class="sd"> device : {None, string, SyclDevice, SyclQueue, Device}, optional</span>
16811682
<span class="sd"> An array API concept of device where the output array is created.</span>
1682-
<span class="sd"> The `device` can be ``None`` (the default), an OneAPI filter selector</span>
1683-
<span class="sd"> string, an instance of :class:`dpctl.SyclDevice` corresponding to</span>
1684-
<span class="sd"> a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,</span>
1685-
<span class="sd"> or a `Device` object returned by</span>
1686-
<span class="sd"> :obj:`dpnp.dpnp_array.dpnp_array.device` property.</span>
1683+
<span class="sd"> `device` can be ``None``, a oneAPI filter selector string, an instance</span>
1684+
<span class="sd"> of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL</span>
1685+
<span class="sd"> device, an instance of :class:`dpctl.SyclQueue`, or a</span>
1686+
<span class="sd"> :class:`dpctl.tensor.Device` object returned by</span>
1687+
<span class="sd"> :attr:`dpnp.ndarray.device`.</span>
1688+
16871689
<span class="sd"> Default: ``None``.</span>
16881690
<span class="sd"> usm_type : {None, &quot;device&quot;, &quot;shared&quot;, &quot;host&quot;}, optional</span>
16891691
<span class="sd"> The type of SYCL USM allocation for the output array.</span>

_modules/dpnp/linalg/dpnp_iface_linalg.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
</script>
1515

1616
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
17-
<title>dpnp.linalg.dpnp_iface_linalg &mdash; Data Parallel Extension for NumPy 0.17.0dev6+20.gf56a43f4892 documentation</title>
17+
<title>dpnp.linalg.dpnp_iface_linalg &mdash; Data Parallel Extension for NumPy 0.17.0dev7+3.gaf0fc93fad5 documentation</title>
1818
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=03e43079" />
1919
<link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=e59714d7" />
2020

2121

2222
<script src="../../../_static/jquery.js?v=5d32c60e"></script>
2323
<script src="../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
24-
<script src="../../../_static/documentation_options.js?v=dbee7e7a"></script>
24+
<script src="../../../_static/documentation_options.js?v=7237ab0c"></script>
2525
<script src="../../../_static/doctools.js?v=9bcbadda"></script>
2626
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
2727
<script src="../../../_static/js/theme.js"></script>

0 commit comments

Comments
 (0)