BUG: ive is nan from |x| near 2e9 on, inherited from scipy.special.ive (scipy/scipy#18088)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 67/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- backend, machine-learning
Research direction
The issue identifies PyTensor’s scalar Ive implementation and the HSGPPeriodic spectral density as the affected paths, but names no source file or test. Start by locating Ive and its tests, then trace how it calls scipy.special.ive; reproduce the reported values near 2e9 and check the existing large-argument behavior. Done means large inputs return finite values consistent with the asymptotic behavior and the regression is covered by a test.
Written by the indexing model from the issue text.
Description
Describe the issue:
pt.ive(v, x) is nan from |x| of about 2e9 on, where the function is finite and smooth, close to 1 / sqrt(2 pi |x|). The nan comes from scipy.special.ive (AMOS reports a loss of significance, scipy/scipy#18088, open since 2023). Since PyTensor's Ive calls SciPy, it inherits it, and HSGPPeriodic's spectral density, ive(j, 1 / ls**2), is nan for a lengthscale below about 2.2e-5, which NUTS then rejects.
A fallback to the asymptotic expansion for large |x| in PyTensor's scalar Ive would avoid the NaN without waiting on SciPy.
Reproducible code example:
import numpy as np
import pytensor.tensor as pt
import scipy.special as sp
for x in [1e9, 2e9, 3e9]:
x = np.float64(x)
print(f"x={x:g}: pt.ive(0, x) = {float(pt.ive(0, x).eval())}, scipy = {sp.ive(0, x)}, 1/sqrt(2 pi x) = {1 / np.sqrt(2 * np.pi * x):.6e}")
x=1e+09: pt.ive(0, x) = 1.261566261167776e-05, scipy = 1.261566261167776e-05, 1/sqrt(2 pi x) = 1.261566e-05
x=2e+09: pt.ive(0, x) = nan, scipy = nan, 1/sqrt(2 pi x) = 8.920621e-06
x=3e+09: pt.ive(0, x) = nan, scipy = nan, 1/sqrt(2 pi x) = 7.283656e-06
mpmath at 50 digits: ive(0, 2e9) = 8.92062058132e-06 and ive(0, 3e9) = 7.28365620425e-06.
Error message:
None. The value is nan.
PyTensor version information:
pytensor 3.3.7, scipy 1.18.1, numpy 2.5.4, Python 3.12, macOS arm64.
Context for the issue:
Found while checking the spectral density of HSGPPeriodic at small lengthscales.
- Dominant language
- Python
- Stars
- 655
- Forks
- 266
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 43
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pymc-devs/pytensor
-
BUG: cumsum and cumprod keep bool and small integer dtypes, so cumsum(x > 0) is wrongPossibly taken @rishabhsai claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Docs of mode still mentions C/CVM as the default with FAST_RUNPossibly taken @ADITYASINGH1206 claimed this 13 days ago. Opendocs
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pymc-devs/pytensor#2641 · 1 comment ·
Maintainers usually reply within 1 day
-
Update conditions page in docsPossibly taken @caxaxa claimed this 3 days ago. Opendocs
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
BUG: geomspace returns wrong sign for the endpoints when start and stop are negativePossibly taken @mayuriphad claimed this 32 days ago. Open
Difficulty 2/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Reciprocal.impl computes np.float32(1.0) / x: float32 precision for float64 scalars under NEP 50 (Python linker)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
pymc-devs/pytensor#2430 · 1 comment ·
Maintainers usually reply within 1 day
All issues in pymc-devs/pytensor
Similar issues
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
kornia/kornia-rs#1416 · 1 comment ·
Maintainers usually reply within 2 days
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PolicyEngine/ai-inequality#64 ·
Maintainers usually reply within 1 day
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timePossibly taken @PabloRoque claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
pymc-devs/pymc-extras#839 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day