Skip to content

Commit 4d67708

Browse files
Fix dpnp.linspace returning NaN for equal infinite endpoints (#3043)
`dpnp.linspace` returned `NaN` instead of the endpoint value when `start` and `stop` are equal and infinite — e.g. `dpnp.linspace(inf, inf, 4)` gave `[nan inf inf nan]`. The bug had two independent sources: - The array path in `dpnp_linspace` computed `delta = stop - start`, so `inf - inf = NaN` propagated through the whole result. - The scalar path delegates to `dpnp.tensor.linspace`, whose affine kernel `LinearSequenceAffineFunctor` evaluates `start * w + stop * wc`; at the endpoints one weight is `0`, and `inf * 0 = NaN`. The PR proposes to fix all the places. Note, the tests compare against NumPy on versions that include the fix (NumPy >= 2.6.0) and fall back to explicit expected values on older NumPy. 94dcfef
1 parent 3c9213a commit 4d67708

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

_modules/dpnp/dpnp_iface_arraycreation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3984,7 +3984,7 @@ <h1>Source code for dpnp.dpnp_iface_arraycreation</h1><div class="highlight"><pr
39843984
<span class="sd"> There are `num` equally spaced samples in the closed interval</span>
39853985
<span class="sd"> [`start`, `stop`] or the half-open interval [`start`, `stop`)</span>
39863986
<span class="sd"> (depending on whether `endpoint` is ``True`` or ``False``).</span>
3987-
<span class="sd"> step : float, optional</span>
3987+
<span class="sd"> step : dpnp.ndarray, optional</span>
39883988
<span class="sd"> Only returned if `retstep` is ``True``.</span>
39893989
<span class="sd"> Size of spacing between samples.</span>
39903990

backend_doc/doxygen_crawl.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
<a href="gemm_8hpp_source.html"/>
1616
<a href="gemv_8hpp_source.html"/>
1717
<a href="syrk_8hpp_source.html"/>
18-
<a href="blas_2types__matrix_8hpp_source.html"/>
19-
<a href="lapack_2types__matrix_8hpp_source.html"/>
2018
<a href="common__internal_8hpp_source.html"/>
2119
<a href="validation__utils__internal_8hpp_source.html"/>
2220
<a href="dispatch__table_8hpp_source.html"/>
2321
<a href="validation__utils_8hpp_source.html"/>
22+
<a href="common_2ext_2common_8hpp_source.html"/>
23+
<a href="elementwise__functions_2common_8hpp_source.html"/>
24+
<a href="fft_2common_8hpp_source.html"/>
25+
<a href="ufunc_2elementwise__functions_2common_8hpp_source.html"/>
26+
<a href="vm_2common_8hpp_source.html"/>
27+
<a href="window_2common_8hpp_source.html"/>
2428
<a href="elementwise__functions_8hpp_source.html"/>
2529
<a href="elementwise__functions__type__utils_8hpp_source.html"/>
2630
<a href="simplify__iteration__space_8hpp_source.html"/>
@@ -47,19 +51,13 @@
4751
<a href="potrf_8hpp_source.html"/>
4852
<a href="syevd_8hpp_source.html"/>
4953
<a href="syevd__batch_8hpp_source.html"/>
54+
<a href="blas_2types__matrix_8hpp_source.html"/>
55+
<a href="lapack_2types__matrix_8hpp_source.html"/>
5056
<a href="ungqr_8hpp_source.html"/>
5157
<a href="bincount_8hpp_source.html"/>
5258
<a href="histogram__common_8hpp_source.html"/>
5359
<a href="histogramdd_8hpp_source.html"/>
5460
<a href="sliding__dot__product1d_8hpp_source.html"/>
55-
<a href="common_2ext_2common_8hpp_source.html"/>
56-
<a href="elementwise__functions_2common_8hpp_source.html"/>
57-
<a href="fft_2common_8hpp_source.html"/>
58-
<a href="ufunc_2elementwise__functions_2common_8hpp_source.html"/>
59-
<a href="vm_2common_8hpp_source.html"/>
60-
<a href="window_2common_8hpp_source.html"/>
61-
<a href="ufunc_2elementwise__functions_2erf__funcs_8hpp_source.html"/>
62-
<a href="vm_2erf__funcs_8hpp_source.html"/>
6361
<a href="float__power_8hpp_source.html"/>
6462
<a href="populate_8hpp_source.html"/>
6563
<a href="abs_8hpp_source.html"/>
@@ -79,6 +77,8 @@
7977
<a href="cos_8hpp_source.html"/>
8078
<a href="cosh_8hpp_source.html"/>
8179
<a href="div_8hpp_source.html"/>
80+
<a href="ufunc_2elementwise__functions_2erf__funcs_8hpp_source.html"/>
81+
<a href="vm_2erf__funcs_8hpp_source.html"/>
8282
<a href="exp_8hpp_source.html"/>
8383
<a href="exp2_8hpp_source.html"/>
8484
<a href="expm1_8hpp_source.html"/>

reference/comparison.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@
10551055
<h1>Comparison Table NumPy/ DPNP/ CuPy<a class="headerlink" href="#comparison-table-numpy-dpnp-cupy" title="Link to this heading">¶</a></h1>
10561056
<p>Here is a list of NumPy and CuPy APIs and its corresponding DPNP implementations.</p>
10571057
<p><code class="docutils literal notranslate"><span class="pre">-</span></code> in DPNP column means that DPNP implementation is not provided yet.</p>
1058-
<p><strong>NumPy(v2.5.2) / DPNP(v0.21.0dev7+11.g1bfd8e6f6fe) / CuPy(v14.2.0) APIs</strong></p>
1058+
<p><strong>NumPy(v2.5.2) / DPNP(v0.21.0dev7+13.g94dcfef845a) / CuPy(v14.2.0) APIs</strong></p>
10591059
<section id="summary">
10601060
<h2>Summary<a class="headerlink" href="#summary" title="Link to this heading">¶</a></h2>
10611061
<div class="table-wrapper docutils container">

reference/generated/dpnp.linspace.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ <h1>dpnp.linspace<a class="headerlink" href="#dpnp-linspace" title="Link to this
11081108
<li><p><strong>out</strong> (<em>dpnp.ndarray</em>) -- There are <cite>num</cite> equally spaced samples in the closed interval
11091109
[<cite>start</cite>, <cite>stop</cite>] or the half-open interval [<cite>start</cite>, <cite>stop</cite>)
11101110
(depending on whether <cite>endpoint</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code>).</p></li>
1111-
<li><p><strong>step</strong> (<em>float, optional</em>) -- Only returned if <cite>retstep</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>.
1111+
<li><p><strong>step</strong> (<em>dpnp.ndarray, optional</em>) -- Only returned if <cite>retstep</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>.
11121112
Size of spacing between samples.</p></li>
11131113
</ul>
11141114
</p>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)