Skip to content

Commit

Permalink
MAINT: stats: use renamed _biasedurn and add deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Oct 26, 2021
1 parent 3928e43 commit a0593f9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ scipy/stats/mvnmodule.c
scipy/stats/statlibmodule.c
scipy/stats/vonmises_cython.c
scipy/stats/_stats.c
scipy/stats/_biasedurn.cxx
scipy/stats/_biasedurn.pyx
scipy/stats/biasedurn.cxx
scipy/stats/biasedurn.pyx
scipy/stats/_sobol.c
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ignore_missing_imports = True
[mypy-scipy.optimize._trlib._trlib]
ignore_missing_imports = True

[mypy-scipy.stats.biasedurn]
[mypy-scipy.stats._biasedurn]
ignore_missing_imports = True

[mypy-scipy.stats._boost.*]
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/_discrete_distns.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
rv_discrete, _ncx2_pdf, _ncx2_cdf, get_distribution_names,
_check_shape)
import scipy.stats._boost as _boost
from .biasedurn import (_PyFishersNCHypergeometric,
from ._biasedurn import (_PyFishersNCHypergeometric,
_PyWalleniusNCHypergeometric,
_PyStochasticLib3)

Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/_generate_pyx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def isNPY_OLD():

def make_biasedurn():
'''Substitute True/False values for NPY_OLD Cython build variable.'''
biasedurn_base = (pathlib.Path(__file__).parent / 'biasedurn').absolute()
biasedurn_base = (pathlib.Path(__file__).parent / '_biasedurn').absolute()
with open(biasedurn_base.with_suffix('.pyx.templ'), 'r') as src:
contents = src.read()
with open(biasedurn_base.with_suffix('.pyx'), 'w') as dest:
Expand Down
29 changes: 29 additions & 0 deletions scipy/stats/biasedurn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is not meant for public use and will be removed in SciPy v2.0.0.


import warnings
from . import _biasedurn


__all__ = [ # noqa: F822
'_PyFishersNCHypergeometric',
'_PyWalleniusNCHypergeometric',
'_PyStochasticLib3'
]


def __dir__():
return __all__


def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.stats.biasedurn is deprecated and has no attribute "
f"{name}.")

warnings.warn("the `scipy.stats.biasedurn` namespace is deprecated and "
"will be removed in SciPy v2.0.0.",
category=DeprecationWarning, stacklevel=2)

return getattr(_biasedurn, name)
2 changes: 1 addition & 1 deletion scipy/stats/mvn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.stats.mvn is deprecated and has no attribute "
f"{name}. Try looking in scipy.special instead.")
f"{name}. Try looking in scipy.stats instead.")

warnings.warn(f"Please use `{name}` from the `scipy.stats` namespace, "
"the `scipy.stats.mvn` namespace is deprecated.",
Expand Down
6 changes: 3 additions & 3 deletions scipy/stats/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def configuration(parent_package='', top_path=None):
config.ext_modules.append(ext)

# add BiasedUrn module
config.add_data_files('biasedurn.pxd')
config.add_data_files('_biasedurn.pxd')
from _generate_pyx import isNPY_OLD # type: ignore[import]
NPY_OLD = isNPY_OLD()

Expand All @@ -70,9 +70,9 @@ def configuration(parent_package='', top_path=None):
biasedurn_libdirs += get_info('npymath')['library_dirs']

ext = config.add_extension(
'biasedurn',
'_biasedurn',
sources=[
'biasedurn.cxx',
'_biasedurn.cxx',
'biasedurn/impls.cpp',
'biasedurn/fnchyppr.cpp',
'biasedurn/wnchyppr.cpp',
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/statlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.stats.statlib is deprecated and has no attribute "
f"{name}. Try looking in scipy.special instead.")
f"{name}. Try looking in scipy.stats instead.")

warnings.warn(f"Please use `{name}` from the `scipy.stats` namespace, "
"the `scipy.stats.statlib` namespace is deprecated.",
Expand Down

0 comments on commit a0593f9

Please sign in to comment.