<br><br><div class="gmail_quote">On Nov 10, 2007 3:33 PM, Michael McNeil Forbes <<a href="mailto:firstname.lastname@example.org" target="_blank">email@example.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Why are numpy warnings printed rather than issued using the standard<br>warnings library? I know that the behaviour can be controlled by<br>seterr(), but it seem rather unpythonic not to use the warnings library.<br><br>
Is there an explicit reason for this choice? (It seems like a pretty<br>trivial modification of util.py will catch most of the cases.) If<br>performance is an issue, one could add a 'print' mode which behaves<br>
as the current 'warn'.</blockquote><div><br>I believe that performance is at least part of the reason. I suspect that routing things through the Python warnings module is somewhat expensive and there are some things that one usually want to ignore (underflow for example). It's not the cases where warnings are printed that are a performance issue; it's the cases where something dodgy happens but you are intentionally ignoring it that could cause performance issues.
<br><br>In principle, I think that you could get away with just using seterr to turn warnings on and off and use the warnings framework to do everything else. However, the warnings framework has always been harder for me to work with than seterr, so I'm not keen on that myself.
<br><br>What might well make sense is to route things through the warnings module only when seterr is set to "warn" for that error type. <br><br></div></div><br>-- <br>. __<br>. |-\<br>.<br>. <a href="mailto:firstname.lastname@example.org" target="_blank">