[Numpy-discussion] Warnings in numpy.ma.test()
Wed Mar 17 10:33:29 CDT 2010
On Wed, Mar 17, 2010 at 9:20 AM, Darren Dale <firstname.lastname@example.org> wrote:
> On Wed, Mar 17, 2010 at 10:11 AM, Ryan May <email@example.com> wrote:
>> On Wed, Mar 17, 2010 at 7:19 AM, Darren Dale <firstname.lastname@example.org> wrote:
>>> Is this general enough for your use case? I haven't tried to think
>>> about how to change some global state at one point and change it back
>>> at another, that seems like a bad idea and difficult to support.
>> Sounds like the textbook use case for the python 2.5/2.6 context
>> manager. Pity we can't use it yet... (and I'm not sure it'd be easy
>> to wrap around the calls here.)
> I don't think context managers would work. They would be implemented
> in one of the subclasses special methods and would thus go out of
> scope before the ufunc got around to performing the calculation that
> required the change in state.
Right, that's the part I was referring to in the last part of my post.
But the concept of modifying global state and ensuring that no matter
what happens, that state reset to its initial condition, is the
textbook use case for context managers.
Problem is, I think that limitation replies to any method that tries
to be exception-safe. It seems like you basically need to wrap the
initial function call.
Graduate Research Assistant
School of Meteorology
University of Oklahoma
More information about the NumPy-Discussion