|
14 | 14 | </script> |
15 | 15 |
|
16 | 16 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
17 | | - <title>dpnp.dpnp_array — Data Parallel Extension for NumPy 0.20.0dev2+20.g9d6d5a50e6f documentation</title> |
| 17 | + <title>dpnp.dpnp_array — Data Parallel Extension for NumPy 0.20.0dev2+21.g9c4aed22eb8 documentation</title> |
18 | 18 | <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" /> |
19 | 19 | <link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=9edc463e" /> |
20 | 20 |
|
21 | 21 |
|
22 | 22 | <script src="../../_static/jquery.js?v=5d32c60e"></script> |
23 | 23 | <script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> |
24 | | - <script src="../../_static/documentation_options.js?v=3ba98b21"></script> |
| 24 | + <script src="../../_static/documentation_options.js?v=20ce9460"></script> |
25 | 25 | <script src="../../_static/doctools.js?v=9bcbadda"></script> |
26 | 26 | <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> |
27 | 27 | <script src="../../_static/js/theme.js"></script> |
@@ -1623,35 +1623,54 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre> |
1623 | 1623 | <a class="viewcode-back" href="../../reference/generated/dpnp.dpnp_array.dpnp_array.partition.html#dpnp.dpnp_array.dpnp_array.partition">[docs]</a> |
1624 | 1624 | <span class="k">def</span><span class="w"> </span><span class="nf">partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="n">kth</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="s2">"introselect"</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> |
1625 | 1625 | <span class="w"> </span><span class="sd">"""</span> |
1626 | | -<span class="sd"> Return a partitioned copy of an array.</span> |
| 1626 | +<span class="sd"> Partially sorts the elements in the array in such a way that the value</span> |
| 1627 | +<span class="sd"> of the element in k-th position is in the position it would be in a</span> |
| 1628 | +<span class="sd"> sorted array. In the output array, all elements smaller than the k-th</span> |
| 1629 | +<span class="sd"> element are located to the left of this element and all equal or</span> |
| 1630 | +<span class="sd"> greater are located to its right. The ordering of the elements in the</span> |
| 1631 | +<span class="sd"> two partitions on the either side of the k-th element in the output</span> |
| 1632 | +<span class="sd"> array is undefined.</span> |
1627 | 1633 |
|
1628 | | -<span class="sd"> Rearranges the elements in the array in such a way that the value of</span> |
1629 | | -<span class="sd"> the element in `kth` position is in the position it would be in</span> |
1630 | | -<span class="sd"> a sorted array.</span> |
| 1634 | +<span class="sd"> Refer to `dpnp.partition` for full documentation.</span> |
1631 | 1635 |
|
1632 | | -<span class="sd"> All elements smaller than the `kth` element are moved before this</span> |
1633 | | -<span class="sd"> element and all equal or greater are moved behind it. The ordering</span> |
1634 | | -<span class="sd"> of the elements in the two partitions is undefined.</span> |
| 1636 | +<span class="sd"> kth : {int, sequence of ints}</span> |
| 1637 | +<span class="sd"> Element index to partition by. The kth element value will be in its</span> |
| 1638 | +<span class="sd"> final sorted position and all smaller elements will be moved before</span> |
| 1639 | +<span class="sd"> it and all equal or greater elements behind it.</span> |
| 1640 | +<span class="sd"> The order of all elements in the partitions is undefined. If</span> |
| 1641 | +<span class="sd"> provided with a sequence of kth it will partition all elements</span> |
| 1642 | +<span class="sd"> indexed by kth of them into their sorted position at once.</span> |
| 1643 | +<span class="sd"> axis : int, optional</span> |
| 1644 | +<span class="sd"> Axis along which to sort. The default is ``-1``, which means sort</span> |
| 1645 | +<span class="sd"> along the the last axis.</span> |
1635 | 1646 |
|
1636 | | -<span class="sd"> Refer to `dpnp.partition` for full documentation.</span> |
| 1647 | +<span class="sd"> Default: ``-1``.</span> |
1637 | 1648 |
|
1638 | 1649 | <span class="sd"> See Also</span> |
1639 | 1650 | <span class="sd"> --------</span> |
1640 | 1651 | <span class="sd"> :obj:`dpnp.partition` : Return a partitioned copy of an array.</span> |
| 1652 | +<span class="sd"> :obj:`dpnp.argpartition` : Indirect partition.</span> |
| 1653 | +<span class="sd"> :obj:`dpnp.sort` : Full sort.</span> |
1641 | 1654 |
|
1642 | 1655 | <span class="sd"> Examples</span> |
1643 | 1656 | <span class="sd"> --------</span> |
1644 | 1657 | <span class="sd"> >>> import dpnp as np</span> |
1645 | 1658 | <span class="sd"> >>> a = np.array([3, 4, 2, 1])</span> |
1646 | 1659 | <span class="sd"> >>> a.partition(3)</span> |
1647 | 1660 | <span class="sd"> >>> a</span> |
| 1661 | +<span class="sd"> array([1, 2, 3, 4]) # may vary</span> |
| 1662 | + |
| 1663 | +<span class="sd"> >>> a.partition((1, 3))</span> |
| 1664 | +<span class="sd"> >>> a</span> |
1648 | 1665 | <span class="sd"> array([1, 2, 3, 4])</span> |
1649 | 1666 |
|
1650 | 1667 | <span class="sd"> """</span> |
1651 | 1668 |
|
1652 | | - <span class="bp">self</span><span class="o">.</span><span class="n">_array_obj</span> <span class="o">=</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">partition</span><span class="p">(</span> |
1653 | | - <span class="bp">self</span><span class="p">,</span> <span class="n">kth</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> |
1654 | | - <span class="p">)</span><span class="o">.</span><span class="n">get_array</span><span class="p">()</span></div> |
| 1669 | + <span class="k">if</span> <span class="n">axis</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> |
| 1670 | + <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span> |
| 1671 | + <span class="s2">"'NoneType' object cannot be interpreted as an integer"</span> |
| 1672 | + <span class="p">)</span> |
| 1673 | + <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">partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">kth</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> |
1655 | 1674 |
|
1656 | 1675 |
|
1657 | 1676 | <div class="viewcode-block" id="dpnp_array.prod"> |
|
0 commit comments