[Numpy-discussion] Warnings in NumPy SVN
Fernando Perez
Fernando.Perez at colorado.edu
Thu Apr 27 12:58:02 EDT 2006
David M. Cooke wrote:
> Fernando Perez <Fernando.Perez at colorado.edu> writes:
>
>
>>Sasha wrote:
>>
>>>On 4/27/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
>>>
>>>
>>>>[...]
>>>>The function (or macro) needs to implement the operation on the basic
>>>>data-type and if necessary set an error-flag in the floating-point
>>>>registers.
>>>>
>>>>If anybody has time to help implement these basic operations, it would
>>>>be greatly appreciated.
>>>
>>>I can help. To make sure we don't duplicate our effort, let's do
>>>the following:
>>>1. I will add place-holders for all the necessary functions to make
>>>them return "NotImplemented".
>>
>>just a minor reminder:
>>
>> raise NotImplementedError
>>
>>is the standard idiom for this.
>
>
> Just a note: For __xxx__ methods, "return NotImplemented" is the
> standard idiom. See section 3.3.8 (Coercion rules) of the Python 2.4
> language manual:
>
> For most intents and purposes, an operator that returns
> NotImplemented is treated the same as one that is not implemented
> at all.
>
> I believe the idea is that it's not actually an error for an __xxx__
> method to not be implemented, as there are fallbacks.
You are right. It's worth remembering that the actual syntaxes are
return NotImplemented
and
raise NotImplementedError
/without/ quotes (as per the original msg), since these are actual python
builtins, not strings. That way they can be properly handled by their return
value or proper exception handling.
Cheers,
f
More information about the NumPy-Discussion
mailing list