Skip to content

Conversation

@j-towns
Copy link
Collaborator

@j-towns j-towns commented Mar 1, 2017

There are various (admittedly quite obscure) situations where Numpy might throw a keyerror, and it could be incorrectly caught by this try ... except block, which would obscure the correct error. This slight rearrangement should prevent that from happening.

@j-towns
Copy link
Collaborator Author

j-towns commented Mar 1, 2017

A dumb example of what I'm talking about:

from autograd.core import primitive
from autograd import grad
import numpy as np

@primitive
def sin(x):
    return np.sin(x)

def sin_vjp(g, ans, vs, gvs, x):
    # generate a keyerror
    d = dict()
    d['a']

sin.defvjp(sin_vjp)

grad(sin)(1.)

seems to throw three exceptions, two of which are

NotImplementedError: Gradient of sin w.r.t. arg number 0 not yet implemented.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant