[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #578 from musicinmybrain/getargspec
Browse files Browse the repository at this point in the history
Replace inspect.getargspec on Python 3
  • Loading branch information
j-towns committed Jun 15, 2022
2 parents fc1bfa4 + 116f738 commit cb5f840
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions autograd/differential_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from __future__ import absolute_import
from functools import partial
from collections import OrderedDict
from inspect import getargspec
try:
from inspect import getfullargspec as _getargspec # Python 3
except ImportError:
from inspect import getargspec as _getargspec # Python 2
import warnings

from .wrap_util import unary_to_nary
Expand Down Expand Up @@ -69,7 +72,7 @@ def holomorphic_grad(fun, x):
def grad_named(fun, argname):
'''Takes gradients with respect to a named argument.
Doesn't work on *args or **kwargs.'''
arg_index = getargspec(fun).args.index(argname)
arg_index = _getargspec(fun).args.index(argname)
return grad(fun, arg_index)

@unary_to_nary
Expand Down

0 comments on commit cb5f840

Please sign in to comment.