[Numpy-discussion] Release blockers for 1.4.0 ?

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Dec 8 00:47:33 EST 2009


On Mon, Dec 7, 2009 at 11:54 PM, David Cournapeau
<david at ar.media.kyoto-u.ac.jp> wrote:
> josef.pktd at gmail.com wrote:
>>
>> warning is no problem, but I haven't figured out what the pattern is
>> for repeated warnings.
>>
>
> By default, warnings are only 'raised' once. You need to use the
> standard warnings module to control the behavior (always warn, raise,
> etc...). Look for the simplefilter function in the python documentation
> for the details.
>
> Now, it is not that simple because the divide by zero is not a python
> warning, but a simple printf on stderr if I understand  correctly what
> Pauli said.
>
>> When I do the same zero division several times, I only get the warning
>> the first time, after that no warning is printed anymore. I don't know
>> about the scope of the non-printing. If it is globally, so that only
>> the first warning is printed, then it won't really help in detecting
>> errors. ?
>
> Both FPU exception handling and warning handling can be set up locally -
> it is just a bit tricky to do because it should be considered as a
> resource to be freed, that is it should always be restored to the
> previous state no matter what. That's what context manager (with the
> with keyword) are for in python >=2.6, and you should use try/finally
> block otherwise.

Thanks, sounds clear now. I guess we can expect some user questions if
suddenly the number of warnings increases again.

contextlib was introduced in python 2.5

http://docs.scipy.org/numpy/docs/numpy-docs/user/misc.rst/    mentions
that the default in numpy is warn. Maybe adding some basic information
about using pythons warning module to control the warnings could be
added here to the docs (and in notes of seterr).

I will remember to reset it, if I ever need to change it temporarily
>>> seterrold = np.seterr()
>>> np.seterr(**seterrold)

Cheers,

Josef


>
> cheers,
>
> David
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list