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

DeprecationWarning: inspect.getargspec() is deprecated in phrases.py:317 #1878

Closed
Diyago opened this issue Feb 4, 2018 · 8 comments
Closed
Labels
bug Issue described a bug difficulty easy Easy issue: required small fix good first issue Issue for new contributors (not required gensim understanding + very simple)

Comments

@Diyago
Copy link

Diyago commented Feb 4, 2018

Description

I wanted to add bigrams/trigrams by using Phrases() but something went wrong

Steps/Code/Corpus to Reproduce

from gensim.models import Phrases 
#1st way to get error
bigram_model = Phrases()

#2nd way to get error
bigram_model = Phrases(['aaa', 'aaa'])

Expected Results

Two get bigrams. I have got them, but I have confused by the errors/warnings below

Actual Results

C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):
C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):
C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):
C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):
C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):
C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\gensim\models\phrases.py:317: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  if all(parameter in getargspec(scoring)[0] for parameter in scoring_parameters):

Please paste or specifically describe the actual output or traceback. -->

Versions

Windows-10-10.0.15063-SP0
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]
NumPy 1.14.0
SciPy 0.19.1
gensim 3.3.0
FAST_VERSION 1
@menshikh-iv
Copy link
Contributor

Hello @Diyago, thanks for the report, this is an only warning, not an error, the model works fine.
Anyway, we should replace getargspec because this is deprecated.

@menshikh-iv menshikh-iv added bug Issue described a bug breaks backward-compatibility Change breaks backward compatibility good first issue Issue for new contributors (not required gensim understanding + very simple) difficulty easy Easy issue: required small fix and removed breaks backward-compatibility Change breaks backward compatibility labels Feb 5, 2018
@naveenkumarmarri
Copy link

@menshikh-iv what is the expected behavior in python 2.7? I think we should still use getargspec()

correct me if I'm wrong

@menshikh-iv
Copy link
Contributor

@naveenkumarmarri for 2.7 getargspec is fine, this deprecated since python 3.0 (https://docs.python.org/3/library/inspect.html#inspect.getargspec). We still use getagrspec for py2, but for py3 need to fix this problem.

@aneesh-joshi
Copy link
Contributor

@menshikh-iv
I am trying to reproduce the error on a windows 10 with python 3.6.3

This is what I get:

(gensim_env) (base) D:\Projects\gensim>python test_script.py
D:\Projects\gensim\gensim\utils.py:1167: UserWarning: detected Windows; aliasing chunkize to chunkize_serial
  warnings.warn("detected Windows; aliasing chunkize to chunkize_serial")
Phrases<2 vocab, min_count=5, threshold=10.0, max_vocab_size=40000000>

(gensim_env) (base) D:\Projects\gensim>python --version
Python 3.6.3 :: Anaconda, Inc.

The chunkize part is fine. The file I'm running has the code provided by @Diyago

@menshikh-iv
Copy link
Contributor

@aneesh-joshi try to force warnings: python -Wd test_script.py

@aneesh-joshi
Copy link
Contributor

aneesh-joshi commented Feb 8, 2018

@menshikh-iv
I managed to remove the warning by replacing getargspec with getfullargspec as suggested in https://docs.python.org/3/library/inspect.html#inspect.getargspec

However, it is only for python 3 and won't work for python 2.

Is there any way to use different functions depending on the python version.

Moreover, forcing warnings brings out some other deprecation warnings

(gensim_env) (base) D:\Projects\gensim>python -Wd test_script.py
D:\Projects\gensim\gensim_env\lib\site.py:165: DeprecationWarning: 'U' mode is deprecated
  f = open(fullname, "rU")
D:\Projects\gensim\gensim_env\lib\site-packages\boto\plugin.py:40: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
D:\Projects\gensim\gensim\utils.py:1167: UserWarning: detected Windows; aliasing chunkize to chunkize_serial
  warnings.warn("detected Windows; aliasing chunkize to chunkize_serial")
D:\Projects\gensim\gensim_env\lib\importlib\_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
D:\Projects\gensim\gensim_env\lib\site-packages\scipy\sparse\sparsetools.py:20: DeprecationWarning: 
scipy.sparse.sparsetools` is deprecated!
scipy.sparse.sparsetools is a private module for scipy.sparse, and should not be used.
  _deprecated()

Should I do anything about this?

@menshikh-iv
Copy link
Contributor

@aneesh-joshi yes, you can fix this if you use needed function (depends on python version) or probably six (I'm not sure about it).

About sparsetools, you can't do anything right now, we want to make our own "spasetools subset" package as GSoC task.

@aneesh-joshi
Copy link
Contributor

@menshikh-iv
Please review the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue described a bug difficulty easy Easy issue: required small fix good first issue Issue for new contributors (not required gensim understanding + very simple)
Projects
None yet
Development

No branches or pull requests

4 participants