Skip to content

Commit

Permalink
DEP: integrate: improve deprecation of private modules named without …
Browse files Browse the repository at this point in the history
…underscore prefix (#18970)

also alphabetize PRIVATE_BUT_PRESENT_MODULES
  • Loading branch information
j-bowhay committed Jul 30, 2023
1 parent d81a72b commit 604e7a2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 71 deletions.
15 changes: 10 additions & 5 deletions scipy/_lib/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def test_dir_testing():
'scipy.fftpack.helper',
'scipy.fftpack.pseudo_diffs',
'scipy.fftpack.realtransforms',
'scipy.integrate.odepack',
'scipy.integrate.quadpack',
'scipy.integrate.dop',
'scipy.integrate.lsoda',
'scipy.integrate.odepack',
'scipy.integrate.quadpack',
'scipy.integrate.vode',
'scipy.interpolate.dfitpack',
'scipy.interpolate.fitpack',
Expand All @@ -98,8 +98,6 @@ def test_dir_testing():
'scipy.io.arff.arffread',
'scipy.io.harwell_boeing',
'scipy.io.idl',
'scipy.io.mmio',
'scipy.io.netcdf',
'scipy.io.matlab.byteordercodes',
'scipy.io.matlab.mio',
'scipy.io.matlab.mio4',
Expand All @@ -109,6 +107,8 @@ def test_dir_testing():
'scipy.io.matlab.mio_utils',
'scipy.io.matlab.miobase',
'scipy.io.matlab.streams',
'scipy.io.mmio',
'scipy.io.netcdf',
'scipy.linalg.basic',
'scipy.linalg.decomp',
'scipy.linalg.decomp_cholesky',
Expand Down Expand Up @@ -317,7 +317,12 @@ def check_importable(module_name):


@pytest.mark.parametrize(("module_name", "correct_module"),
[('scipy.optimize.cobyla', None),
[('scipy.integrate.dop', None),
('scipy.integrate.lsoda', None),
('scipy.integrate.odepack', None),
('scipy.integrate.quadpack', None),
('scipy.integrate.vode', None),
('scipy.optimize.cobyla', None),
('scipy.optimize.lbfgsb', None),
('scipy.optimize.linesearch', None),
('scipy.optimize.minpack', None),
Expand Down
18 changes: 4 additions & 14 deletions scipy/integrate/dop.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This file is not meant for public use and will be removed in SciPy v2.0.0.


import warnings
from . import _dop # type: ignore

from scipy._lib.deprecation import _sub_module_deprecation

__all__ = [ # noqa: F822
'dopri5',
Expand All @@ -16,13 +13,6 @@ def __dir__():


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

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

return getattr(_dop, name)
return _sub_module_deprecation(sub_package="integrate", module="dop",
private_module="_dop", all=__all__,
attribute=name)
18 changes: 4 additions & 14 deletions scipy/integrate/lsoda.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This file is not meant for public use and will be removed in SciPy v2.0.0.


import warnings
from . import _lsoda # type: ignore

from scipy._lib.deprecation import _sub_module_deprecation

__all__ = ['lsoda'] # noqa: F822

Expand All @@ -13,13 +10,6 @@ def __dir__():


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

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

return getattr(_lsoda, name)
return _sub_module_deprecation(sub_package="integrate", module="lsoda",
private_module="_lsoda", all=__all__,
attribute=name)
16 changes: 4 additions & 12 deletions scipy/integrate/odepack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Use the `scipy.integrate` namespace for importing the functions
# included below.

import warnings
from . import _odepack_py
from scipy._lib.deprecation import _sub_module_deprecation

__all__ = ['odeint', 'ODEintWarning'] # noqa: F822

Expand All @@ -13,13 +12,6 @@ def __dir__():


def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.integrate.odepack is deprecated and has no attribute "
f"{name}. Try looking in scipy.integrate instead.")

warnings.warn(f"Please use `{name}` from the `scipy.integrate` namespace, "
"the `scipy.integrate.odepack` namespace is deprecated.",
category=DeprecationWarning, stacklevel=2)

return getattr(_odepack_py, name)
return _sub_module_deprecation(sub_package="integrate", module="odepack",
private_module="_odepack_py", all=__all__,
attribute=name)
16 changes: 4 additions & 12 deletions scipy/integrate/quadpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Use the `scipy.integrate` namespace for importing the functions
# included below.

import warnings
from . import _quadpack_py
from scipy._lib.deprecation import _sub_module_deprecation

__all__ = [ # noqa: F822
"quad",
Expand All @@ -20,13 +19,6 @@ def __dir__():


def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.integrate.quadpack is deprecated and has no attribute "
f"{name}. Try looking in scipy.integrate instead.")

warnings.warn(f"Please use `{name}` from the `scipy.integrate` namespace, "
"the `scipy.integrate.quadpack` namespace is deprecated.",
category=DeprecationWarning, stacklevel=2)

return getattr(_quadpack_py, name)
return _sub_module_deprecation(sub_package="integrate", module="quadpack",
private_module="_quadpack_py", all=__all__,
attribute=name)
18 changes: 4 additions & 14 deletions scipy/integrate/vode.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This file is not meant for public use and will be removed in SciPy v2.0.0.


import warnings
from . import _vode # type: ignore

from scipy._lib.deprecation import _sub_module_deprecation

__all__ = [ # noqa: F822
'dvode',
Expand All @@ -16,13 +13,6 @@ def __dir__():


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

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

return getattr(_vode, name)
return _sub_module_deprecation(sub_package="integrate", module="vode",
private_module="_vode", all=__all__,
attribute=name)

0 comments on commit 604e7a2

Please sign in to comment.