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

Standardize traceback. #10515

Merged
merged 1 commit into from
May 9, 2017
Merged

Standardize traceback. #10515

merged 1 commit into from
May 9, 2017

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented May 7, 2017

Compress user and location of stdlib/sitepackage.
That should make traceback identical on all machines, hopefully making
Google a bit better at finding them, and a little less wide in many
case.

The drawback is that filename are not copy-pastable to edit files, unless
situated somewhere not in site packages but that should be the case for
most dev install, so I expect that to not bother many people.


In [1]: import numpy; numpy.histogram('a')
---------------------------------------------------------------------------
With $STDLIB='/Users/bussonniermatthias/anaconda/lib/python3.6':
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-e5edd817948c> in <module>()
----> 1 import numpy; numpy.histogram('a')

$STDLIB/site-packages/numpy/lib/function_base.py in histogram(a, bins, range, normed, weights, density)
    659             mn, mx = 0.0, 1.0
    660         else:
--> 661             mn, mx = a.min() + 0.0, a.max() + 0.0
    662     else:
    663         mn, mx = [mi + 0.0 for mi in range]

$STDLIB/site-packages/numpy/core/_methods.py in _amin(a, axis, out, keepdims)
     27
     28 def _amin(a, axis=None, out=None, keepdims=False):
---> 29     return umr_minimum(a, axis, None, out, keepdims)
     30
     31 def _sum(a, axis=None, dtype=None, out=None, keepdims=False):

TypeError: cannot perform reduce with flexible type

@takluyver I feel like you will be opinionated on this one.

I'm flexible on the naming and what we compress, but I think it would be great to do that.

@Carreau Carreau force-pushed the std-tb branch 2 times, most recently from 2df5ddf to 6f44b0a Compare May 8, 2017 04:37
@takluyver
Copy link
Member

takluyver commented May 8, 2017

I'm happy enough to use the compress_user function to abbreviate the home directory as ~. That saves some space, and you can still copy and paste the path to open it, at least on Unix.

I'm not convinced on $STDLIB, $SITE-PACKAGES, etc. I don't really like the separate delimited block at the top explaining variables. I don't like the $SUGGESTION that these are environment variables or shell variables. And both the standard library and site-packages can be in multiple locations (e.g. virtualenvs, Debian's dist-packages directories), so the simplifications won't work consistently.

@takluyver I feel like you will be opinionated on this one.

It's like you know me! 😛

Counterproposal

What makes the line so long is having the path and the function signature in one line. From your example, histogram(a, bins, range, normed, weights, density) is already 51 characters, so with the in, you only have 25 characters for the path before you hit 80 columns. What about putting them on separate lines:

~/anaconda/lib/python3.6/site-packages/numpy/lib/function_base.py
  in histogram(a, bins, range, normed, weights, density)

There the first line is only 65 characters.

We could either do this on every frame (simple and consistent), or only where the single line would exceed some length (so foo.py in bar() would still be on one line).

@Carreau
Copy link
Member Author

Carreau commented May 8, 2017

Yeah, I though about a large refactoring of traceback, you can even omit the filename if two consecutive frames have the same file, and I don't want to go this route (for now), counting line length with current architecture would be a pain.

I've push a simpler commit that just compress_user, and I'm fine delaying any other refactoring for later. If you think of any better layout please let me know.

How does that sounds ?

@takluyver
Copy link
Member

Sounds reasonable. Let's go with compress_user and see how we get on.

@takluyver takluyver merged commit 30dced8 into ipython:master May 9, 2017
@Carreau Carreau deleted the std-tb branch May 25, 2017 02:01
@Carreau Carreau added this to the 6.1 milestone May 29, 2017
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.

2 participants