Fwd: [Numpy-discussion] Bump warning stacklevel
Stéfan van der Walt
stefanv at berkeley.edu
Wed Jan 27 13:37:37 EST 2016
Devs, please note the thread below.
---------- Forwarded message ----------
From: Sebastian Berg <sebastian at sipsolutions.net>
Date: Wed, Jan 27, 2016 at 10:26 AM
Subject: [Numpy-discussion] Bump warning stacklevel
To: Discussion of Numerical Python <numpy-discussion at scipy.org>
Hi all,
in my PR about warnings suppression, I currently also have a commit
which bumps the warning stacklevel to two (or three), i.e. use:
warnings.warn(..., stacklevel=2)
(almost) everywhere. This means that for example (take only the empty
warning):
np.mean([])
would not print:
/usr/lib/python2.7/dist-packages/numpy/core/_methods.py:55:
RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
but instead print the actual `np.mean([])` code line (the repetition of
the warning command is always a bit funny).
The advantage is nicer printing for the user.
The disadvantage would probably mostly be that existing warning filters
that use the `module` keyword argument, will fail.
Any objections/thoughts about doing this change to try to better report
the offending code line? Frankly, I am not sure whether there might be
a python standard about this, but I would expect that for a library
such as numpy, it makes sense to change. But, if downstream uses
warning filters with modules, we might want to reconsider for example.
- Sebastian
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion at scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20160127/3191d8e5/attachment.sig>
More information about the scikit-image
mailing list