Skip to content

Commit 3788c7a

Browse files
Add implementation of dpnp.ndarray.tolist method (#2652)
The PR adds implementation of `dpnp.ndarray.tolist` method converting the array to `numpy.ndarray` and calling `.tolist()` for the result. Additionally the documentation is extended with rendering of `Input and output` page, aligning with NumPy and CuPy dos. 904cbd6
1 parent 9668ccd commit 3788c7a

File tree

753 files changed

+2618
-1529
lines changed

Some content is hidden

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

753 files changed

+2618
-1529
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: ceb2cceb5a82ca4219ae071a18a589db
3+
config: a0efdc31207cc5a98956ab9d1787ef75
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_modules/dpnp/dpnp_array.html

Lines changed: 50 additions & 3 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.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>
@@ -2221,7 +2221,54 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
22212221

22222222
<span class="c1"># &#39;tobytes&#39;,</span>
22232223
<span class="c1"># &#39;tofile&#39;,</span>
2224-
<span class="c1"># &#39;tolist&#39;,</span>
2224+
2225+
<div class="viewcode-block" id="dpnp_array.tolist">
2226+
<a class="viewcode-back" href="../../reference/generated/dpnp.dpnp_array.dpnp_array.tolist.html#dpnp.dpnp_array.dpnp_array.tolist">[docs]</a>
2227+
<span class="k">def</span><span class="w"> </span><span class="nf">tolist</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
2228+
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
2229+
<span class="sd"> Converts the array to a (possibly nested) Python list.</span>
2230+
2231+
<span class="sd"> For full documentation refer to :obj:`numpy.ndarray.tolist`.</span>
2232+
2233+
<span class="sd"> Returns</span>
2234+
<span class="sd"> -------</span>
2235+
<span class="sd"> out : list</span>
2236+
<span class="sd"> The possibly nested Python list of array elements.</span>
2237+
2238+
<span class="sd"> Examples</span>
2239+
<span class="sd"> --------</span>
2240+
<span class="sd"> For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,</span>
2241+
<span class="sd"> except that ``tolist`` changes 0D arrays to Python scalars:</span>
2242+
2243+
<span class="sd"> &gt;&gt;&gt; import dpnp as np</span>
2244+
<span class="sd"> &gt;&gt;&gt; a = np.array([1, 2])</span>
2245+
<span class="sd"> &gt;&gt;&gt; list(a)</span>
2246+
<span class="sd"> [array(1), array(2)]</span>
2247+
<span class="sd"> &gt;&gt;&gt; a.tolist()</span>
2248+
<span class="sd"> [1, 2]</span>
2249+
2250+
<span class="sd"> Additionally, for a 2D array, ``tolist`` applies recursively:</span>
2251+
2252+
<span class="sd"> &gt;&gt;&gt; a = np.array([[1, 2], [3, 4]])</span>
2253+
<span class="sd"> &gt;&gt;&gt; list(a)</span>
2254+
<span class="sd"> [array([1, 2]), array([3, 4])]</span>
2255+
<span class="sd"> &gt;&gt;&gt; a.tolist()</span>
2256+
<span class="sd"> [[1, 2], [3, 4]]</span>
2257+
2258+
<span class="sd"> The base case for this recursion is a 0D array:</span>
2259+
2260+
<span class="sd"> &gt;&gt;&gt; a = np.array(1)</span>
2261+
<span class="sd"> &gt;&gt;&gt; list(a)</span>
2262+
<span class="sd"> Traceback (most recent call last):</span>
2263+
<span class="sd"> ...</span>
2264+
<span class="sd"> TypeError: iteration over a 0-d array</span>
2265+
<span class="sd"> &gt;&gt;&gt; a.tolist()</span>
2266+
<span class="sd"> 1</span>
2267+
2268+
<span class="sd"> &quot;&quot;&quot;</span>
2269+
2270+
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span></div>
2271+
22252272

22262273
<div class="viewcode-block" id="dpnp_array.trace">
22272274
<a class="viewcode-back" href="../../reference/generated/dpnp.dpnp_array.dpnp_array.trace.html#dpnp.dpnp_array.dpnp_array.trace">[docs]</a>

_modules/dpnp/dpnp_array_api_info.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.dpnp_array_api_info &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_array_api_info &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_flatiter.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.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface.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.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface_arraycreation.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.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface_bitwise.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.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface_counting.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.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface_functional.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.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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>

_modules/dpnp/dpnp_iface_histograms.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.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.20.0dev0+28.gaa5800eb90 documentation</title>
17+
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.20.0dev0+29.g904cbd6ccb2 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=1db0075e"></script>
24+
<script src="../../_static/documentation_options.js?v=b7cb34b8"></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)