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

BUG: skip deprecation for numpy top-level types #11066

Merged
merged 1 commit into from Nov 16, 2019

Conversation

pv
Copy link
Member

@pv pv commented Nov 16, 2019

Deprecation decoration of type objects is more likely to cause problems
than for functions, so don't do it. Deprecation of plain functions is
likely enough to result to deprecation warnings in most cases.

This would likely be important to fix for Scipy 1.4.0, as otherwise we break
the backward compatibility here.

E.g. the array scalar type objects are often used in dtype= arguments
and possibly compared with other scalar objects, and our deprecation
decoration currently breaks that:

>>> import scipy, numpy as np
>>> assert scipy.array([1,2,3], dtype=scipy.float64).dtype == np.float64
__main__:1: DeprecationWarning: scipy.array is deprecated and will be removed in SciPy 2.0.0, use numpy.array instead
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pauli/prj/scipy/scipy/scipy/_lib/deprecation.py", line 14, in call
    return fun(*args, **kwargs)
TypeError: data type not understood
>>> assert scipy.float64 == np.float64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError

It's possible to do the decoration so that the above still works, via
subclassing with metaclass, but it's hard to be sure that covers everything
necessary. Since deprecation of functions already likely generates deprecation
warnings in suspect code, it's probably enough.

Deprecation decoration of type objects is more likely to cause problems
than for functions, so don't do it. Deprecation of plain functions is
likely enough to result to deprecation warnings in most cases.
@pv pv added this to the 1.4.0 milestone Nov 16, 2019
@pv pv requested a review from larsoner November 16, 2019 14:24
@rgommers rgommers added the maintenance Items related to regular maintenance tasks label Nov 16, 2019
@pv pv added the defect A clear bug or issue that prevents SciPy from being installed or used as expected label Nov 16, 2019
@rgommers
Copy link
Member

Makes sense, thanks @pv.

Since this should go into 1.4.0rc1 and we're branching that today, I'll hit the green button. @larsoner would be good to still have a look

@rgommers rgommers merged commit 09fe64c into scipy:master Nov 16, 2019
@larsoner
Copy link
Member

Agreed that this is safer/better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected maintenance Items related to regular maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants