Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEP: linalg: improve deprecation of private modules named without underscore prefix #19035

Merged
merged 5 commits into from Aug 16, 2023

Conversation

j-bowhay
Copy link
Member

@j-bowhay j-bowhay commented Aug 9, 2023

Reference issue

toward #18279

What does this implement/fix?

Currently some of the deprecation warnings for private modules named without underscore prefix are misleading. For example:
Before this pr:

In [2]: from scipy.linalg.basic import levinson
<ipython-input-2-6918a53fe48c>:1: DeprecationWarning: Please use `levinson` from the `scipy.linalg` namespace, the `scipy.linalg.basic` namespace is deprecated.
  from scipy.linalg.basic import levinson

In [3]: from scipy.linalg import levinson
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 from scipy.linalg import levinson

ImportError: cannot import name 'levinson' from 'scipy.linalg' (/home/jakeb/development/scipy/build-install/lib/python3.10/site-packages/scipy/linalg/__init__.py)

After:

In [5]: from scipy.linalg.basic import levinson
<ipython-input-5-6918a53fe48c>:1: DeprecationWarning: `scipy.linalg.basic.levinson` is deprecated along with the `scipy.linalg.basic` namespace. `scipy.linalg.basic.levinson` will be removed in SciPy 1.13.0, and the `scipy.linalg.basic` namespace will be removed in SciPy 2.0.0.

This also reduces code duplication and strengthens testing.

Additional information

@j-bowhay j-bowhay added scipy.linalg deprecated Items related to behavior that has been deprecated labels Aug 9, 2023
@@ -14,7 +14,7 @@ def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.linalg.flinalg is deprecated and has no attribute "
f"{name}. Try looking in scipy.linalg instead.")
f"{name}.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure about the best course of action here. Everything in the __all__ of this module doesn't appear in scipy.linalg. This means if _sub_module_deprecation was used then they would all be stated for removal from __all__ in 1.13.0 but then there would be nothing left in the module. However, the module isn't due to be removed until 2.0.0 hence why I just modified the message directly.

Copy link
Member

@ilayn ilayn Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't remove it just to stay out of your deprecation efforts, but indeed it is empty. So we can remove it since det and lu was living in here. And they are already available under linalg namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it strange that we're keeping around an empty module, but the warning has already promised that'd we'd only remove it for 2.0.0, so 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess nobody anticipated that we would touch Fortran code. But I think that promise is void now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #19072

Copy link
Member

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :)

@@ -14,7 +14,7 @@ def __getattr__(name):
if name not in __all__:
raise AttributeError(
"scipy.linalg.flinalg is deprecated and has no attribute "
f"{name}. Try looking in scipy.linalg instead.")
f"{name}.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it strange that we're keeping around an empty module, but the warning has already promised that'd we'd only remove it for 2.0.0, so 🤷

@ilayn ilayn changed the title DEP: interpolate: improve deprecation of private modules named without underscore prefix DEP: linalg: improve deprecation of private modules named without underscore prefix Aug 11, 2023
@j-bowhay
Copy link
Member Author

Everyone happy if we hit the button?

@h-vetinari
Copy link
Member

Actually, this now needs to take into account the changes from #19067, e.g. we need to remove the np.cast aliases:

E   ImportError: cannot import name 'cast' from 'numpy'

@j-bowhay
Copy link
Member Author

updated

@h-vetinari h-vetinari merged commit 840a9ed into scipy:main Aug 16, 2023
23 of 25 checks passed
@h-vetinari
Copy link
Member

Thanks @j-bowhay! :)

@lucascolley lucascolley added this to the 1.12.0 milestone Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated Items related to behavior that has been deprecated scipy.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants