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

Preserve stack trace when a curried function fails #62

Open
jni opened this issue Apr 7, 2015 · 5 comments
Open

Preserve stack trace when a curried function fails #62

jni opened this issue Apr 7, 2015 · 5 comments

Comments

@jni
Copy link

jni commented Apr 7, 2015

I'm not sure how difficult this is or how it would affect performance, but it sure as hell would be more fun to debug things!

Current stack trace:

883     >>> montaged = list(montage_stream(images, [[0, 1], [2, 3]], [2, 0, 1]))
UNEXPECTED EXCEPTION: TypeError()
Traceback (most recent call last):

  File "/Users/nuneziglesiasj/anaconda/envs/mic3/lib/python3.4/doctest.py", line 1318, in __run
    compileflags, 1), test.globs)

  File "<doctest microscopium.preprocess.montage_stream[1]>", line 1, in <module>

  File "/Volumes/Projects/microscopium/microscopium/preprocess.py", line 903, in montage_stream
    curried.map(stack_channels(channel_order)),

  File "cytoolz/functoolz.pyx", line 252, in cytoolz.functoolz.curry.__call__ (cytoolz/functoolz.c:3296)

TypeError

/Volumes/Projects/microscopium/microscopium/preprocess.py:883: UnexpectedException

The actual error, after some sleuthing around in IPython:

----> 1 def is_array(obj): return isinstance(obj, np.array)

TypeError: isinstance() arg 2 must be a type or tuple of types
@eriknw
Copy link
Member

eriknw commented Apr 7, 2015

I agree this would be nice. I don't know whether this is possible or not, but we can look into it.

@mrocklin
Copy link
Member

mrocklin commented Apr 7, 2015

When looking into profiling cython code I learned that there was a flag you could set. That's an option.

Alternatively @jni you could use toolz.curry if performance isn't that big of an issue.

We could also capture the exception, capture the traceback, and then raise a new exception with that printed out traceback. This is what I do in dask. It's a bit of a pain to do. Contributions welcome :)

@jni
Copy link
Author

jni commented Apr 8, 2015

@mrocklin it won't happen immediately but I'll post here if I grab some time to start on this.

Slightly related: have you guys measured the performance hit of currying functions? i.e. why not curry all the things?

@mrocklin
Copy link
Member

mrocklin commented Apr 8, 2015

Erik benchmarked this extensively.

We did curry all the things. Have you seen the toolz.curried namespace?

@jni
Copy link
Author

jni commented Apr 8, 2015

@mrocklin yes, but why is that not the default namespace. ;)

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

No branches or pull requests

3 participants