Skip to content

Commit

Permalink
Add dpnp.iterable function (#2208)
Browse files Browse the repository at this point in the history
There was `__iter__` method of dpnp.ndarray implemented in scope of
#2206.

While this PR proposes to add implementation of `dpnp.iterable` function
which is intended to check if the object (including dpnp.ndarray) can be
iterated over.
The implementation leverages on NumPy call, which is based on attempt to
pass the object to `iter` function. 3f737be
  • Loading branch information
github-actions[bot] committed Dec 4, 2024
1 parent fec8b69 commit 22f6644
Show file tree
Hide file tree
Showing 1,031 changed files with 1,981 additions and 1,727 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 5ed3e8071361ce5f9018f129d6f2ce3c
config: e2c599844a613400f27c0ec1aff4d087
tags: 645f666f9bcd5a90fca523b33c5a78b7
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_array.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_flatiter.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_arraycreation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_bitwise.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_counting.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_functional.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_histograms.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
49 changes: 47 additions & 2 deletions _modules/dpnp/dpnp_iface_indexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_indexing &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_indexing &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down Expand Up @@ -154,6 +154,7 @@ <h1>Source code for dpnp.dpnp_iface_indexing</h1><div class="highlight"><pre>
<span class="s2">&quot;fill_diagonal&quot;</span><span class="p">,</span>
<span class="s2">&quot;flatnonzero&quot;</span><span class="p">,</span>
<span class="s2">&quot;indices&quot;</span><span class="p">,</span>
<span class="s2">&quot;iterable&quot;</span><span class="p">,</span>
<span class="s2">&quot;ix_&quot;</span><span class="p">,</span>
<span class="s2">&quot;mask_indices&quot;</span><span class="p">,</span>
<span class="s2">&quot;ndindex&quot;</span><span class="p">,</span>
Expand Down Expand Up @@ -1145,6 +1146,50 @@ <h1>Source code for dpnp.dpnp_iface_indexing</h1><div class="highlight"><pre>



<div class="viewcode-block" id="iterable">
<a class="viewcode-back" href="../../reference/generated/dpnp.iterable.html#dpnp.iterable">[docs]</a>
<span class="k">def</span> <span class="nf">iterable</span><span class="p">(</span><span class="n">y</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Check whether or not an object can be iterated over.</span>

<span class="sd"> For full documentation refer to :obj:`numpy.iterable`.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> y : object</span>
<span class="sd"> Input object.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> out : bool</span>
<span class="sd"> Return ``True`` if the object has an iterator method or is a sequence</span>
<span class="sd"> and ``False`` otherwise.</span>

<span class="sd"> Examples</span>
<span class="sd"> --------</span>
<span class="sd"> &gt;&gt;&gt; import dpnp as np</span>
<span class="sd"> &gt;&gt;&gt; np.iterable([1, 2, 3])</span>
<span class="sd"> True</span>
<span class="sd"> &gt;&gt;&gt; np.iterable(2)</span>
<span class="sd"> False</span>

<span class="sd"> In most cases, the results of ``np.iterable(obj)`` are consistent with</span>
<span class="sd"> ``isinstance(obj, collections.abc.Iterable)``. One notable exception is</span>
<span class="sd"> the treatment of 0-dimensional arrays:</span>

<span class="sd"> &gt;&gt;&gt; from collections.abc import Iterable</span>
<span class="sd"> &gt;&gt;&gt; a = np.array(1.0) # 0-dimensional array</span>
<span class="sd"> &gt;&gt;&gt; isinstance(a, Iterable)</span>
<span class="sd"> True</span>
<span class="sd"> &gt;&gt;&gt; np.iterable(a)</span>
<span class="sd"> False</span>

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

<span class="k">return</span> <span class="n">numpy</span><span class="o">.</span><span class="n">iterable</span><span class="p">(</span><span class="n">y</span><span class="p">)</span></div>



<div class="viewcode-block" id="ix_">
<a class="viewcode-back" href="../../reference/generated/dpnp.ix_.html#dpnp.ix_">[docs]</a>
<span class="k">def</span> <span class="nf">ix_</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_libmath.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_libmath &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_libmath &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_linearalgebra.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_linearalgebra &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_linearalgebra &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_logic.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_logic &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_logic &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_manipulation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_manipulation &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_manipulation &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_mathematical.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_mathematical &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_mathematical &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_nanfunctions.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_nanfunctions &mdash; Data Parallel Extension for NumPy 0.17.0dev2+28.ged39ea75812 documentation</title>
<title>dpnp.dpnp_iface_nanfunctions &mdash; Data Parallel Extension for NumPy 0.17.0dev3 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d5a05a36"></script>
<script src="../../_static/documentation_options.js?v=49df5c2b"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
Loading

0 comments on commit 22f6644

Please sign in to comment.