BUG: NumPy's `random` module should not be in the `scipy` namespace.
See original GitHub issueDescribe your issue.
Currently, scipy.random
is an alias for numpy.random
:
In [12]: import numpy as np
In [13]: import scipy
In [14]: scipy.__version__
Out[14]: '1.8.0.dev0+1859.14341ea'
In [15]: scipy.random
Out[15]: <module 'numpy.random' from '/home/warren/mc39scipy/lib/python3.9/site-packages/numpy/random/__init__.py'>
In [16]: scipy.random is np.random
Out[16]: True
We have already deprecated other names in scipy
that come from numpy
, e.g.
In [17]: scipy.array([1, 2, 3])
<ipython-input-17-773c09c10413>:1: DeprecationWarning: scipy.array is deprecated and will be removed in SciPy 2.0.0, use numpy.array instead
scipy.array([1, 2, 3])
Out[17]: array([1, 2, 3])
We should do the same for random
, so a call such as the following generates a deprecation warning:
In [18]: scipy.random.randint(10, size=3)
Out[18]: array([8, 5, 5])
Reproducing Code Example
See above.
Error message
See above.
SciPy/NumPy/Python version information
1.8.0.dev0+1859.14341ea 1.21.2 sys.version_info(major=3, minor=9, micro=5, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Python's random module made inaccessible by Numpy's ...
I've tried importing numpy under a different name, which doesn't fix the problem.
Read more >Making clearer what namespaces are public by use ... - GitHub
The public namespaces are documented in http://scipy.github.io/devdocs/ ... BUG: NumPy's random module should not be in the scipy namespace.
Read more >SciPy API — SciPy v1.9.3 Manual
In SciPy there are modules whose names don't start with an underscore, but that should be considered private. To clarify which modules these...
Read more >SciPy 1.9.0 Release Notes — SciPy v1.9.3 Manual
This release requires Python 3.8-3.11 and NumPy 1.18.5 or greater. ... #14889: BUG: NumPy's `random` module should not be in the `scipy`…
Read more >SciPy 1.4.0 Release Notes — SciPy v1.9.3 Manual
Support for NumPy functions exposed via the root SciPy namespace is deprecated and will be removed in 2.0.0. For example, if you use...
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
Not really an API break but actually fixes something that should have not happened anyways but just a missed star import. So it’s not really a big deal. And it didn’t create any noise so let’s close it and deal when it becomes an issue.
@andyfaff, according to the deprecation warning, the other
numpy
names are scheduled to be removed from SciPy 2.0.0.random
should follow the same schedule.