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

Inconsistent error messages when passing bad arguments to primitives #2904

Open
gnecula opened this issue Apr 30, 2020 · 0 comments
Open

Inconsistent error messages when passing bad arguments to primitives #2904

gnecula opened this issue Apr 30, 2020 · 0 comments
Labels
better_errors Improve the error reporting

Comments

@gnecula
Copy link
Collaborator

gnecula commented Apr 30, 2020

Our transformation API functions check the arguments passed in: _check_args and you get a nice error message.

This is not true of our lax.primitives, e.g., np.sin(lambda x: x) gives an error from inside numpy about "data type not understood". Perhaps this is Ok, but I noticed that in the bind implementation we do check the type of arguments (but only if skip_checks is False).

If the invocation with bad arguments is under transformations even the find_top_trace inside bind will malfunction. In some cases this means that it will return None and the impl rule will be called. At least this means that you get the same error (from numpy). In other cases, it will simply "not see" the bad argument (because it only looks for Tracers).

Would it make sense to add the _check_args as part of bind, essentially removing the skip_checks guard from the type check? Or, if performance is a concern, have a flavor of checked_bind that is used in the API.

@mattjj mattjj added the better_errors Improve the error reporting label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better_errors Improve the error reporting
Projects
None yet
Development

No branches or pull requests

2 participants