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

Deprecation warnings: scipy.sparse.sparsetools and np.float #3014

Open
raffaem opened this issue Dec 20, 2020 · 11 comments
Open

Deprecation warnings: scipy.sparse.sparsetools and np.float #3014

raffaem opened this issue Dec 20, 2020 · 11 comments
Assignees
Labels
difficulty easy Easy issue: required small fix impact LOW Low impact on affected users need info Not enough information for reproduce an issue, need more info from author reach HIGH Affects most or all Gensim users

Comments

@raffaem
Copy link

raffaem commented Dec 20, 2020

Problem description

Run the test for the new version of WEFE

Steps/code/corpus to reproduce

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/scipy/sparse/sparsetools.py:21
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/scipy/sparse/sparsetools.py:21: DeprecationWarning: `scipy.sparse.sparsetools` is deprecated!
  scipy.sparse.sparsetools is a private module for scipy.sparse, and should not be used.
    _deprecated()

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:34
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:34: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    method='lar', copy_X=True, eps=np.finfo(np.float).eps,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:164
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:164: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    method='lar', copy_X=True, eps=np.finfo(np.float).eps,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:281
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:281: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    eps=np.finfo(np.float).eps, copy_Gram=True, verbose=0,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:865
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:865: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    eps=np.finfo(np.float).eps, copy_X=True, fit_path=True,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1121
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1121: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    eps=np.finfo(np.float).eps, copy_X=True, fit_path=True,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1149
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1149: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    eps=np.finfo(np.float).eps, positive=False):

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1379
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1379: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    max_n_alphas=1000, n_jobs=None, eps=np.finfo(np.float).eps,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1621
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1621: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    max_n_alphas=1000, n_jobs=None, eps=np.finfo(np.float).eps,

../../../../../../home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1755
  /home/raffaele/.virtualenvs/gensim4/lib/python3.8/site-packages/sklearn/linear_model/_least_angle.py:1755: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. Use `float` by itself, which is identical in behavior, to silence this warning. If you specifically wanted the numpy scalar type, use `np.float_` here.
    eps=np.finfo(np.float).eps, copy_X=True, positive=False):

Versions

Please provide the output of:

Linux-5.8.0-33-generic-x86_64-with-glibc2.32
Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0]
Bits 64
NumPy 1.20.0rc1
SciPy 1.6.0rc1
gensim 4.0.0beta
FAST_VERSION 1
@piskvorky
Copy link
Owner

piskvorky commented Dec 20, 2020

Thanks for trying the beta and reporting!

I don't think we can do much about sparsetools (scipy provides no alternative AFAIK), but we can definitely fix the float.

@piskvorky piskvorky added difficulty easy Easy issue: required small fix impact LOW Low impact on affected users reach HIGH Affects most or all Gensim users labels Dec 20, 2020
@piskvorky piskvorky added this to the 4.0.0 milestone Dec 20, 2020
@piskvorky
Copy link
Owner

@raffaem can you run whatever steps you used before, but on the current develop branch of Gensim?

We removed and fixed a bunch of code, so maybe this is not relevant any more. Thanks.

@piskvorky piskvorky added the need info Not enough information for reproduce an issue, need more info from author label Feb 25, 2021
@piskvorky piskvorky self-assigned this Feb 25, 2021
@piskvorky
Copy link
Owner

Removing from 4.0.0. Will revisit when @raffaem follows up.

@piskvorky piskvorky removed this from the 4.0.0 milestone Mar 7, 2021
@FredHappyface
Copy link
Contributor

#3066 is related to this

@robguinness
Copy link
Contributor

I can confirm that the sparsetools DeprecationWarning still exists in gensim 4.0.1. Would it make sense to just squash this warning by surrounding the import with a try/except? The warning is certainly relevant to gensim maintainers, but for gensim users, it's mainly just an annoyance.

@piskvorky
Copy link
Owner

piskvorky commented Apr 7, 2021

Getting rid of (not showing) the sparsetools warning makes sense. But I don't think try-expect will help here – it's not an exception.

As far as I'm aware scipy doesn't offer any alternative for its deprecated (but still functional) sparsetools module. So "fixing" the warning properly is not possible.

@FredHappyface
Copy link
Contributor

I seem to remember there is a way to achieve this sort of thing

I think using warnings.carch_warnings()

https://stackoverflow.com/questions/9134795/how-to-get-rid-of-specific-warning-messages-in-python-while-keeping-all-other-wa

@robguinness
Copy link
Contributor

Update from me: So it turns out that Python's default warning filters will actually filter out DeprecationWarnings, so if you don't for some reason override this, gensim user's won't see these warnings. For some reason though pytest will show these warnings, which is where I was seeing it (see https://stackoverflow.com/a/53218641/896660). I don't really understand why pytest is not using the default warning filters of the python interpreter, but at least there is a way to configure this, so this is the solution in my particular case. I don't think there's anything that needs to be done on gensim's end.

@pabs3
Copy link
Contributor

pabs3 commented May 5, 2022

This was previously discussed in #462 (including with scipy upstream devs).

@pabs3
Copy link
Contributor

pabs3 commented May 5, 2022

Removing scipy from the dependencies was also discussed in #557.

@piskvorky
Copy link
Owner

piskvorky commented May 5, 2022

And in scipy/scipy#5348 by the scipy team.

Scipy (and the whole pydata ecosystem) is much easier to deploy and manage than it was 7 years ago. Plus gensim now compiles its modules too, it's no longer pure python. So many of the assumptions and design edges from the original discussion are no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty easy Easy issue: required small fix impact LOW Low impact on affected users need info Not enough information for reproduce an issue, need more info from author reach HIGH Affects most or all Gensim users
Projects
None yet
Development

No branches or pull requests

5 participants