Skip to content

Commit 8fe8c1a

Browse files
implement sort and argsort (IntelPython#1660)
* implement sort and argsort * add more tests * update for zero dimensional arrays * address comments * fix typo 8072622
1 parent a4dbd51 commit 8fe8c1a

File tree

893 files changed

+5343
-3661
lines changed

Some content is hidden

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

893 files changed

+5343
-3661
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 hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 62628160cde9c0c98026e73119401848
3+
config: 39b11256ab0407620f6b9e20aae8cd94
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_modules/dpnp/dpnp_array.html

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.11.1+426.g249eeb17 documentation</title>
15+
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.11.1+432.g8072622f documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=c1a5ca62"></script>
26+
<script src="../../_static/documentation_options.js?v=f8138ffc"></script>
2727
<script src="../../_static/doctools.js?v=888ff710"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.11.1+426.g249eeb17
46+
0.11.1+432.g8072622f
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -649,39 +649,7 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
649649
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
650650
<span class="sd"> Return an ndarray of indices that sort the array along the specified axis.</span>
651651

652-
<span class="sd"> Parameters</span>
653-
<span class="sd"> ----------</span>
654-
<span class="sd"> axis : int, optional</span>
655-
<span class="sd"> Axis along which to sort. If None, the default, the flattened array</span>
656-
<span class="sd"> is used.</span>
657-
<span class="sd"> .. versionchanged:: 1.13.0</span>
658-
<span class="sd"> Previously, the default was documented to be -1, but that was</span>
659-
<span class="sd"> in error. At some future date, the default will change to -1, as</span>
660-
<span class="sd"> originally intended.</span>
661-
<span class="sd"> Until then, the axis should be given explicitly when</span>
662-
<span class="sd"> ``arr.ndim &gt; 1``, to avoid a FutureWarning.</span>
663-
<span class="sd"> kind : {&#39;quicksort&#39;, &#39;mergesort&#39;, &#39;heapsort&#39;, &#39;stable&#39;}, optional</span>
664-
<span class="sd"> The sorting algorithm used.</span>
665-
<span class="sd"> order : list, optional</span>
666-
<span class="sd"> When `a` is an array with fields defined, this argument specifies</span>
667-
<span class="sd"> which fields to compare first, second, etc. Not all fields need be</span>
668-
<span class="sd"> specified.</span>
669-
670-
<span class="sd"> Returns</span>
671-
<span class="sd"> -------</span>
672-
<span class="sd"> index_array : ndarray, int</span>
673-
<span class="sd"> Array of indices that sort `a` along the specified axis.</span>
674-
<span class="sd"> In other words, ``a[index_array]`` yields a sorted `a`.</span>
675-
676-
<span class="sd"> See Also</span>
677-
<span class="sd"> --------</span>
678-
<span class="sd"> MaskedArray.sort : Describes sorting algorithms used.</span>
679-
<span class="sd"> :obj:`dpnp.lexsort` : Indirect stable sort with multiple keys.</span>
680-
<span class="sd"> :obj:`numpy.ndarray.sort` : Inplace sort.</span>
681-
682-
<span class="sd"> Notes</span>
683-
<span class="sd"> -----</span>
684-
<span class="sd"> See `sort` for notes on the different sorting algorithms.</span>
652+
<span class="sd"> Refer to :obj:`dpnp.argsort` for full documentation.</span>
685653

686654
<span class="sd"> &quot;&quot;&quot;</span>
687655
<span class="k">return</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">argsort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">axis</span><span class="p">,</span> <span class="n">kind</span><span class="p">,</span> <span class="n">order</span><span class="p">)</span></div>
@@ -1375,16 +1343,49 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
13751343

13761344
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_array_obj</span><span class="o">.</span><span class="n">size</span>
13771345

1378-
<span class="c1"># &#39;sort&#39;,</span>
1346+
<div class="viewcode-block" id="dpnp_array.sort">
1347+
<a class="viewcode-back" href="../../reference/generated/dpnp.dpnp_array.dpnp_array.html#dpnp.dpnp_array.dpnp_array.sort">[docs]</a>
1348+
<span class="k">def</span> <span class="nf">sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">axis</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
1349+
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
1350+
<span class="sd"> Sort an array in-place.</span>
1351+
1352+
<span class="sd"> Refer to :obj:`dpnp.sort` for full documentation.</span>
1353+
1354+
<span class="sd"> Note</span>
1355+
<span class="sd"> ----</span>
1356+
<span class="sd"> `axis` in :obj:`dpnp.sort` could be integr or ``None``. If ``None``,</span>
1357+
<span class="sd"> the array is flattened before sorting. However, `axis` in :obj:`dpnp.ndarray.sort`</span>
1358+
<span class="sd"> can only be integer since it sorts an array in-place.</span>
1359+
1360+
<span class="sd"> Examples</span>
1361+
<span class="sd"> --------</span>
1362+
<span class="sd"> &gt;&gt;&gt; import dpnp as np</span>
1363+
<span class="sd"> &gt;&gt;&gt; a = np.array([[1,4],[3,1]])</span>
1364+
<span class="sd"> &gt;&gt;&gt; a.sort(axis=1)</span>
1365+
<span class="sd"> &gt;&gt;&gt; a</span>
1366+
<span class="sd"> array([[1, 4],</span>
1367+
<span class="sd"> [1, 3]])</span>
1368+
<span class="sd"> &gt;&gt;&gt; a.sort(axis=0)</span>
1369+
<span class="sd"> &gt;&gt;&gt; a</span>
1370+
<span class="sd"> array([[1, 1],</span>
1371+
<span class="sd"> [3, 4]])</span>
1372+
1373+
<span class="sd"> &quot;&quot;&quot;</span>
1374+
1375+
<span class="k">if</span> <span class="n">axis</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
1376+
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
1377+
<span class="s2">&quot;&#39;NoneType&#39; object cannot be interpreted as an integer&quot;</span>
1378+
<span class="p">)</span>
1379+
<span class="bp">self</span><span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="n">axis</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">)</span></div>
1380+
13791381

13801382
<div class="viewcode-block" id="dpnp_array.squeeze">
13811383
<a class="viewcode-back" href="../../reference/generated/dpnp.dpnp_array.dpnp_array.html#dpnp.dpnp_array.dpnp_array.squeeze">[docs]</a>
13821384
<span class="k">def</span> <span class="nf">squeeze</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
13831385
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
13841386
<span class="sd"> Remove single-dimensional entries from the shape of an array.</span>
13851387

1386-
<span class="sd"> .. seealso::</span>
1387-
<span class="sd"> :obj:`dpnp.squeeze` for full documentation</span>
1388+
<span class="sd"> Refer to :obj:`dpnp.squeeze` for full documentation</span>
13881389

13891390
<span class="sd"> &quot;&quot;&quot;</span>
13901391

_modules/dpnp/dpnp_flatiter.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.11.1+426.g249eeb17 documentation</title>
15+
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.11.1+432.g8072622f documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=c1a5ca62"></script>
26+
<script src="../../_static/documentation_options.js?v=f8138ffc"></script>
2727
<script src="../../_static/doctools.js?v=888ff710"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.11.1+426.g249eeb17
46+
0.11.1+432.g8072622f
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.11.1+426.g249eeb17 documentation</title>
15+
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.11.1+432.g8072622f documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=c1a5ca62"></script>
26+
<script src="../../_static/documentation_options.js?v=f8138ffc"></script>
2727
<script src="../../_static/doctools.js?v=888ff710"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.11.1+426.g249eeb17
46+
0.11.1+432.g8072622f
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface_arraycreation.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.11.1+426.g249eeb17 documentation</title>
15+
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.11.1+432.g8072622f documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=c1a5ca62"></script>
26+
<script src="../../_static/documentation_options.js?v=f8138ffc"></script>
2727
<script src="../../_static/doctools.js?v=888ff710"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.11.1+426.g249eeb17
46+
0.11.1+432.g8072622f
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -910,7 +910,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
910910

911911
<span class="sd"> Limitations</span>
912912
<span class="sd"> -----------</span>
913-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray`</span>
913+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`</span>
914914
<span class="sd"> Parameter `order` is supported with values ``&quot;C&quot;`` or ``&quot;F&quot;``.</span>
915915
<span class="sd"> Parameter `subok` is supported only with default value ``False``.</span>
916916
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
@@ -1196,7 +1196,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
11961196

11971197
<span class="sd"> Limitations</span>
11981198
<span class="sd"> -----------</span>
1199-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray`</span>
1199+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`</span>
12001200
<span class="sd"> Parameter `order` is supported only with values ``&quot;C&quot;`` and ``&quot;F&quot;``.</span>
12011201
<span class="sd"> Parameter `subok` is supported only with default value ``False``.</span>
12021202
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
@@ -1560,7 +1560,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
15601560

15611561
<span class="sd"> Limitations</span>
15621562
<span class="sd"> -----------</span>
1563-
<span class="sd"> Each array instance from `xi` is supported as either :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray`.</span>
1563+
<span class="sd"> Each array instance from `xi` is supported as either :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`.</span>
15641564
<span class="sd"> Parameter `copy` is supported only with default value ``True``.</span>
15651565
<span class="sd"> Parameter `sparse` is supported only with default value ``False``.</span>
15661566
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
@@ -1823,7 +1823,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
18231823

18241824
<span class="sd"> Limitations</span>
18251825
<span class="sd"> -----------</span>
1826-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray`</span>
1826+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`</span>
18271827
<span class="sd"> Parameter `order` is supported with values ``&quot;C&quot;`` or ``&quot;F&quot;``.</span>
18281828
<span class="sd"> Parameter `subok` is supported only with default value ``False``.</span>
18291829
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
@@ -2002,7 +2002,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
20022002

20032003
<span class="sd"> Limitations</span>
20042004
<span class="sd"> -----------</span>
2005-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray` with two or more dimensions.</span>
2005+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray` with two or more dimensions.</span>
20062006
<span class="sd"> Parameter `k` is supported only of integer data type.</span>
20072007
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
20082008

@@ -2049,7 +2049,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
20492049

20502050
<span class="sd"> Limitations</span>
20512051
<span class="sd"> -----------</span>
2052-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray` with two or more dimensions.</span>
2052+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray` with two or more dimensions.</span>
20532053
<span class="sd"> Parameter `k` is supported only of integer data type.</span>
20542054
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>
20552055

@@ -2246,7 +2246,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
22462246

22472247
<span class="sd"> Limitations</span>
22482248
<span class="sd"> -----------</span>
2249-
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp_array` or :class:`dpctl.tensor.usm_ndarray`</span>
2249+
<span class="sd"> Parameter `x1` is supported as :class:`dpnp.dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`</span>
22502250
<span class="sd"> Parameter `order` is supported with values ``&quot;C&quot;`` or ``&quot;F&quot;``.</span>
22512251
<span class="sd"> Parameter `subok` is supported only with default value ``False``.</span>
22522252
<span class="sd"> Otherwise the function will be executed sequentially on CPU.</span>

_modules/dpnp/dpnp_iface_bitwise.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.11.1+426.g249eeb17 documentation</title>
15+
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.11.1+432.g8072622f documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=c1a5ca62"></script>
26+
<script src="../../_static/documentation_options.js?v=f8138ffc"></script>
2727
<script src="../../_static/doctools.js?v=888ff710"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.11.1+426.g249eeb17
46+
0.11.1+432.g8072622f
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -88,9 +88,7 @@
8888
<div itemprop="articleBody">
8989

9090
<h1>Source code for dpnp.dpnp_iface_bitwise</h1><div class="highlight"><pre>
91-
<span></span><span class="c1"># cython: language_level=3</span>
92-
<span class="c1"># distutils: language = c++</span>
93-
<span class="c1"># -*- coding: utf-8 -*-</span>
91+
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>
9492
<span class="c1"># *****************************************************************************</span>
9593
<span class="c1"># Copyright (c) 2016-2024, Intel Corporation</span>
9694
<span class="c1"># All rights reserved.</span>

0 commit comments

Comments
 (0)