[Numpy-discussion] Scalar-ndarray arguments passed to not_equal

Robert Kern robert.kern at gmail.com
Thu Feb 11 16:11:20 EST 2010


On Thu, Feb 11, 2010 at 15:03, Friedrich Romstedt
<friedrichromstedt at gmail.com> wrote:
> Robert Kern:
>> def numpy_ops(**ops):
>>    old_ops = np.set_numeric_ops(**ops)
>>    try:
>>        yield
>>    finally:
>>        np.set_numeric_ops(**old_ops)
>>
>>
>> with numpy_ops(multiply=...):
>>    print np.array([1, 2, 3]) * np.array([1, 2, 3])
>
> Well, at least for me in Py 2.5 this fails with:
>
> AttributeError: 'generator' object has no attribute '__exit__'

Did you omit the @contextmanager decorator?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list