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 for inspect.getargspec in Python 3.5 #5281

Closed
fonnesbeck opened this Issue Sep 16, 2015 · 23 comments

Comments

Projects
None yet
@fonnesbeck

fonnesbeck commented Sep 16, 2015

When running the current master in Python 3.5.0 (OS X 10.10), I receive DeprecationWarnings every time inspect.getargspec is used. E.g.,

/usr/local/lib/python3.5/site-packages/sklearn/base.py:184: DeprecationWarning: 
inspect.getargspec() is deprecated, use inspect.signature() instead
  args, varargs, kw, default = inspect.getargspec(init)

Incidentally, these warnings cannot be turned off using warnings.simplefilter or warnings.filterwarnings.

@adityapatadia

This comment has been minimized.

Show comment
Hide comment
@adityapatadia

adityapatadia commented Sep 19, 2015

+1

@ruiEnca

This comment has been minimized.

Show comment
Hide comment
@ruiEnca

ruiEnca Sep 19, 2015

+1 (Python 3.5 and Windows 10)

ruiEnca commented Sep 19, 2015

+1 (Python 3.5 and Windows 10)

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Sep 21, 2015

Member

Should we move to using signature and include the 30kb implementation at https://github.com/aliles/funcsigs?

Member

jnothman commented Sep 21, 2015

Should we move to using signature and include the 30kb implementation at https://github.com/aliles/funcsigs?

@prashnts

This comment has been minimized.

Show comment
Hide comment
@prashnts

prashnts Sep 21, 2015

+1
A dirty fix is to replace line 64 of /usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py (or equivalent) with

if 'order' in inspect.signature(np.copy).parameters:

screen shot 2015-09-21 at 11 54 58 pm

prashnts commented Sep 21, 2015

+1
A dirty fix is to replace line 64 of /usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py (or equivalent) with

if 'order' in inspect.signature(np.copy).parameters:

screen shot 2015-09-21 at 11 54 58 pm

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Sep 21, 2015

Member

I think we should try to fix this for the upcoming release...

Member

jnothman commented Sep 21, 2015

I think we should try to fix this for the upcoming release...

@jnothman jnothman added this to the 0.17 milestone Sep 21, 2015

@ogrisel

This comment has been minimized.

Show comment
Hide comment
@ogrisel

ogrisel Sep 22, 2015

Member

I am working on it.

Member

ogrisel commented Sep 22, 2015

I am working on it.

@ogrisel

This comment has been minimized.

Show comment
Hide comment
@ogrisel

ogrisel Sep 22, 2015

Member

A dirty fix is to replace line 64 of /usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py (or equivalent).

There are many occurrences of getargspec in our code base:

doc/sphinxext/numpy_ext/docscrape.py:                argspec = inspect.getargspec(func)
sklearn/base.py:        args, varargs, kw, default = inspect.getargspec(init)
sklearn/calibration.py:            arg_names = inspect.getargspec(base_estimator.fit)[0]
sklearn/externals/joblib/func_inspect.py:    arg_spec = inspect.getargspec(func)
sklearn/externals/joblib/func_inspect.py:                           inspect.formatargspec(*inspect.getargspec(func)),
sklearn/utils/estimator_checks.py:            args = inspect.getargspec(func).args
sklearn/utils/estimator_checks.py:            args, varargs, kws, defaults = inspect.getargspec(init)
sklearn/utils/fixes.py:if 'order' in inspect.getargspec(np.copy)[0]:
sklearn/utils/fixes.py:if 'exist_ok' in inspect.getargspec(os.makedirs).args:
sklearn/utils/validation.py:from inspect import getargspec
sklearn/utils/validation.py:    return parameter in getargspec(estimator.fit)[0]

So maybe including funcsigs in sklearn.externals might indeed be a good idea.

Member

ogrisel commented Sep 22, 2015

A dirty fix is to replace line 64 of /usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py (or equivalent).

There are many occurrences of getargspec in our code base:

doc/sphinxext/numpy_ext/docscrape.py:                argspec = inspect.getargspec(func)
sklearn/base.py:        args, varargs, kw, default = inspect.getargspec(init)
sklearn/calibration.py:            arg_names = inspect.getargspec(base_estimator.fit)[0]
sklearn/externals/joblib/func_inspect.py:    arg_spec = inspect.getargspec(func)
sklearn/externals/joblib/func_inspect.py:                           inspect.formatargspec(*inspect.getargspec(func)),
sklearn/utils/estimator_checks.py:            args = inspect.getargspec(func).args
sklearn/utils/estimator_checks.py:            args, varargs, kws, defaults = inspect.getargspec(init)
sklearn/utils/fixes.py:if 'order' in inspect.getargspec(np.copy)[0]:
sklearn/utils/fixes.py:if 'exist_ok' in inspect.getargspec(os.makedirs).args:
sklearn/utils/validation.py:from inspect import getargspec
sklearn/utils/validation.py:    return parameter in getargspec(estimator.fit)[0]

So maybe including funcsigs in sklearn.externals might indeed be a good idea.

@prashnts

This comment has been minimized.

Show comment
Hide comment
@prashnts

prashnts Sep 22, 2015

I think this would be a good idea:

So maybe including funcsigs in sklearn.externals might indeed be a good idea.`

For example,
sklearn/utils/estimator_checks.py: args, varargs, kws, defaults = inspect.getargspec(init)
inspect.signature does not returns varargs and kws.

A custom implementation would be the better way to wrap over inspect.signature.

prashnts commented Sep 22, 2015

I think this would be a good idea:

So maybe including funcsigs in sklearn.externals might indeed be a good idea.`

For example,
sklearn/utils/estimator_checks.py: args, varargs, kws, defaults = inspect.getargspec(init)
inspect.signature does not returns varargs and kws.

A custom implementation would be the better way to wrap over inspect.signature.

@ogrisel

This comment has been minimized.

Show comment
Hide comment
@ogrisel

ogrisel Sep 23, 2015

Member

A custom implementation would be the better way to wrap over inspect.signature.

I don't want to maintain a custom implementation just use the signature API as provided by funcsigs under Python 2 and the default inspect.signature function in Python 3.3+ and introspect the parameters to find out which is which.

Member

ogrisel commented Sep 23, 2015

A custom implementation would be the better way to wrap over inspect.signature.

I don't want to maintain a custom implementation just use the signature API as provided by funcsigs under Python 2 and the default inspect.signature function in Python 3.3+ and introspect the parameters to find out which is which.

@ogrisel

This comment has been minimized.

Show comment
Hide comment
@ogrisel

ogrisel Sep 23, 2015

Member

I have opened a PR in #5301.

Member

ogrisel commented Sep 23, 2015

I have opened a PR in #5301.

@manugarri

This comment has been minimized.

Show comment
Hide comment
@manugarri

manugarri Nov 20, 2015

+1. tpot is going insane

manugarri commented Nov 20, 2015

+1. tpot is going insane

@GaelVaroquaux

This comment has been minimized.

Show comment
Hide comment
@GaelVaroquaux

GaelVaroquaux Nov 20, 2015

Member

I don't understand your comment, @manugarri : this issue has been fixed via a PR merged a while ago.

Member

GaelVaroquaux commented Nov 20, 2015

I don't understand your comment, @manugarri : this issue has been fixed via a PR merged a while ago.

@manugarri

This comment has been minimized.

Show comment
Hide comment
@manugarri

manugarri Nov 22, 2015

hmm you sure? Im using v 0.16.1 and p3.5 and still showing the error. Maybe it's just fixed in 0.17?

manugarri commented Nov 22, 2015

hmm you sure? Im using v 0.16.1 and p3.5 and still showing the error. Maybe it's just fixed in 0.17?

@manugarri

This comment has been minimized.

Show comment
Hide comment
@manugarri

manugarri Nov 22, 2015

Actually, just updated to 0.17 and the warning is gone. Please close :)

manugarri commented Nov 22, 2015

Actually, just updated to 0.17 and the warning is gone. Please close :)

@yanovskishai

This comment has been minimized.

Show comment
Hide comment
@yanovskishai

yanovskishai Dec 28, 2015

I'm using pandas 0.17.0 with python 3.5.0.final.0 and for some reason I'm still getting the warning
at sklearn/base.py:175

py.warnings - WARNING - /home/rnd/anaconda3/lib/python3.5/site-packages/sklearn/base.py:175: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead args, varargs, kw, default = inspect.getargspec(init)

Is that an expected behavior ?

yanovskishai commented Dec 28, 2015

I'm using pandas 0.17.0 with python 3.5.0.final.0 and for some reason I'm still getting the warning
at sklearn/base.py:175

py.warnings - WARNING - /home/rnd/anaconda3/lib/python3.5/site-packages/sklearn/base.py:175: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead args, varargs, kw, default = inspect.getargspec(init)

Is that an expected behavior ?

@ldacey

This comment has been minimized.

Show comment
Hide comment
@ldacey

ldacey Feb 22, 2016

I am getting this error as well with pandas 0.18 and python 3.5

DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead

ldacey commented Feb 22, 2016

I am getting this error as well with pandas 0.18 and python 3.5

DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead

@amueller

This comment has been minimized.

Show comment
Hide comment
@amueller

amueller Feb 22, 2016

Member

pandas 0.17? how about scikit-learn? ;)

Member

amueller commented Feb 22, 2016

pandas 0.17? how about scikit-learn? ;)

@msequino

This comment has been minimized.

Show comment
Hide comment
@msequino

msequino Mar 28, 2016

The configuration below still gets error.

Python: 3.5.1 | Anaconda: 2.4.0 (64-bit) | Pandas: 0.17.0 | Scikit-learn: 0.17.1 | Numpy 1.10.4

msequino commented Mar 28, 2016

The configuration below still gets error.

Python: 3.5.1 | Anaconda: 2.4.0 (64-bit) | Pandas: 0.17.0 | Scikit-learn: 0.17.1 | Numpy 1.10.4

@erpfeiffer

This comment has been minimized.

Show comment
Hide comment
@erpfeiffer

erpfeiffer Aug 27, 2016

Is there a reliable fix for this? Still getting this error with Python 3.5.2, Pandas 0.18.1, Scikit-Learn 0.17.1, Numpy 1.11.1, Conda 4.1.11. Thanks!

erpfeiffer commented Aug 27, 2016

Is there a reliable fix for this? Still getting this error with Python 3.5.2, Pandas 0.18.1, Scikit-Learn 0.17.1, Numpy 1.11.1, Conda 4.1.11. Thanks!

@jnothman

This comment has been minimized.

Show comment
Hide comment
@jnothman

jnothman Aug 27, 2016

Member

Could @msequino, @erpfeiffer, @ldacey or @yanovskishai please provide a complete example of code that triggers this warning? Thanks.

Member

jnothman commented Aug 27, 2016

Could @msequino, @erpfeiffer, @ldacey or @yanovskishai please provide a complete example of code that triggers this warning? Thanks.

@erpfeiffer

This comment has been minimized.

Show comment
Hide comment
@erpfeiffer

erpfeiffer Aug 27, 2016

Thanks for looking into it. Looks like this is coming from "import pyLDAvis.gensim", but not "import pyLDAvis".

erpfeiffer commented Aug 27, 2016

Thanks for looking into it. Looks like this is coming from "import pyLDAvis.gensim", but not "import pyLDAvis".

@lesteve

This comment has been minimized.

Show comment
Hide comment
@lesteve

lesteve Aug 27, 2016

Member

@erpfeiffer can you provide a snippet that only uses scikit-learn?

Member

lesteve commented Aug 27, 2016

@erpfeiffer can you provide a snippet that only uses scikit-learn?

@erpfeiffer

This comment has been minimized.

Show comment
Hide comment
@erpfeiffer

erpfeiffer Aug 27, 2016

Sorry, I think I've traced it to a different package..

erpfeiffer commented Aug 27, 2016

Sorry, I think I've traced it to a different package..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment