BUG: MultivariateNormalQMC with specific QMCEngine and d == 1 erroneously throws exception
See original GitHub issueDescribe your issue.
With the way the conditional is written in the lines below https://github.com/scipy/scipy/blob/838cfbe51a2aecaba19b24813769ef5aeebfe056/scipy/stats/_qmc.py#L1548
when initializing an MultivariateNormalQMC
instance with d == 1
and an engine that is unquestionably an instance of scipy.stats.qmc.QMCEngine
, we get the ValueError
below. Works fine for d > 1
.
Reproducing Code Example
from scipy.stats.qmc import MultivariateNormalQMC, Sobol
input_dim = 1
engine = Sobol(d=input_dim)
sampler = MultivariateNormalQMC(mean=np.zeros(input_dim), engine=engine)
Error message
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-f2da58e7ebf7> in <module>
----> 1 sampler = MultivariateNormalQMC(mean=np.zeros(1), engine=engine)
~/.virtualenvs/foo/lib/python3.8/site-packages/scipy/stats/_qmc.py in __init__(self, mean, cov, cov_root, inv_transform, engine, seed)
1248 self.engine = engine
1249 else:
-> 1250 raise ValueError("`engine` must be an instance of "
1251 "`scipy.stats.qmc.QMCEngine` or `None`.")
1252
ValueError: `engine` must be an instance of `scipy.stats.qmc.QMCEngine` or `None`.
SciPy/NumPy/Python version information
1.7.1 1.19.5 sys.version_info(major=3, minor=8, micro=10, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
scipy.stats.qmc.MultivariateNormalQMC — SciPy v1.9.3 Manual
A root decomposition of the covariance matrix, where d' may be less than d if the covariance is not full rank. If omitted,...
Read more >Mailman 3 ANN: SciPy 1.9.0 - NumPy-Discussion - python.org
Several BSpline methods now raise an error if inputs have ``ndim > 1``. ... inheritance to `QMCEngine` in `MultinomialQMC` and `MultivariateNormalQMC`.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @tupui for taking a look at this. I understand your previous point and think there is probably a case to be made for both approaches. Ultimately, I’d be happy with either option. Unfortunately, I am not participating in the PyData Sprint and also won’t have much time these days to contribute. Thanks for maintaining the project and keep up the good work!
current:
proposed:
if d=0, d=1, are there tests?