[Numpy-discussion] Release blockers for 1.4.0 ?

Anne Archibald peridot.faceted@gmail....
Wed Dec 9 01:41:55 CST 2009


2009/12/8 Robert Kern <robert.kern@gmail.com>:
> On Tue, Dec 8, 2009 at 15:25, Pierre GM <pgmdevlist@gmail.com> wrote:
>> On Dec 8, 2009, at 12:54 PM, Robert Kern wrote:
>>>
>>> As far as I can tell, the faulty global seterr() has been in place
>>> since 1.1.0, so fixing it at all should be considered a feature
>>> change. It's not likely to actually *break* things except for doctests
>>> and documentation. I think I fall in with Chuck in suggesting that it
>>> should be changed in 1.5.0.
>>
>> OK. I'll work on fixing the remaining issues when a np function is applied on a masked array.
>>
>> FYI. most of the warnings can be fixed in _MaskedUnaryOperation and consorts with:
>>
>>        err_status_ini = np.geterr()
>>        np.seterr(divide='ignore', invalid='ignore')
>>        result = self.f(da, db, *args, **kwargs)
>>        np.seterr(**err_status_ini)
>>
>> Is this kind of fix acceptable ?
>
>  olderr = np.seterr(divide='ignore', invalid='ignore')
>  try:
>    result = self.f(da, db, *args, **kwargs)
>  finally:
>    np.seterr(**olderr)

Doesn't this risk a ctrl-C after the seterr but before the try? How about:
olderr = np.geterr()
try:
    np.seterr(....)
    do_whatever()
finally:
    np.seterr(**olderr)

(I guess this would be why context managers were invented...)

Anne


More information about the NumPy-Discussion mailing list