A while ago we had a brief discussion about this.
Is this a feature? or should there be a ticket for this
np.sqrt('5')
NotImplemented
a = np.sqrt('5') a
NotImplemented
type(a)
<type 'NotImplementedType'>
Josef
On Thu, May 27, 2010 at 9:59 AM, josef.pktd@gmail.com wrote:
A while ago we had a brief discussion about this.
Is this a feature? or should there be a ticket for this
np.sqrt('5')
NotImplemented
a = np.sqrt('5') a
NotImplemented
type(a)
<type 'NotImplementedType'>
Maybe an enhancement ticket. The NotImplemented return is appropriate for some functions, but for functions with a single argument we should probably raise an error.
Chuck
Thu, 27 May 2010 10:21:14 0600, Charles R Harris wrote: [clip]
Maybe an enhancement ticket. The NotImplemented return is appropriate for some functions, but for functions with a single argument we should probably raise an error.
A NotImplemented value leaking to the the user is a bug. The function should raise a ValueError instead.
NotImplemented is meant only for use as a placeholder singleton in implementation of rich comparison operations etc., and we shouldn't introduce any new meanings IMHO.
On Thu, May 27, 2010 at 12:57 PM, Pauli Virtanen pav@iki.fi wrote:
Thu, 27 May 2010 10:21:14 0600, Charles R Harris wrote: [clip]
Maybe an enhancement ticket. The NotImplemented return is appropriate for some functions, but for functions with a single argument we should probably raise an error.
A NotImplemented value leaking to the the user is a bug. The function should raise a ValueError instead.
NotImplemented is meant only for use as a placeholder singleton in implementation of rich comparison operations etc., and we shouldn't introduce any new meanings IMHO.
http://projects.scipy.org/numpy/ticket/1494 with a few examples
I don't know which component
Josef
 Pauli Virtanen
NumPyDiscussion mailing list NumPyDiscussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpydiscussion
On Thu, May 27, 2010 at 9:59 AM, josef.pktd@gmail.com wrote:
A while ago we had a brief discussion about this.
Is this a feature? or should there be a ticket for this
np.sqrt('5')
NotImplemented
a = np.sqrt('5') a
NotImplemented
type(a)
<type 'NotImplementedType'>
What numpy version? I get
In [2]: sqrt(['a'])  NotImplementedError Traceback (most recent call last)
/home/charris/<ipython console> in <module>()
NotImplementedError: Not implemented for this type
In [3]: sqrt('a')  NotImplementedError Traceback (most recent call last)
/home/charris/<ipython console> in <module>()
NotImplementedError: Not implemented for this type
Which is entirely different. Note that Py_NotImplemented is *not* only for comparisons, it is a signal to the interpreter to try the r* version of a binary operator.
OTOH,
In [4]: maximum('a',1) Out[4]: NotImplemented
Which is still a problem. I think no ufunc should return NotImplemented, it should be reserved to methods so the interpreter will handle it correctly.
Chuck
On Thu, May 27, 2010 at 2:34 PM, Charles R Harris charlesr.harris@gmail.com wrote:
On Thu, May 27, 2010 at 9:59 AM, josef.pktd@gmail.com wrote:
A while ago we had a brief discussion about this.
Is this a feature? or should there be a ticket for this
np.sqrt('5')
NotImplemented
a = np.sqrt('5') a
NotImplemented
type(a)
<type 'NotImplementedType'>
What numpy version? I get
Obviously I'm too old (numpy 1.4.0)
Josef
In [2]: sqrt(['a'])
NotImplementedError Traceback (most recent call last)
/home/charris/<ipython console> in <module>()
NotImplementedError: Not implemented for this type
In [3]: sqrt('a')
NotImplementedError Traceback (most recent call last)
/home/charris/<ipython console> in <module>()
NotImplementedError: Not implemented for this type
Which is entirely different. Note that Py_NotImplemented is *not* only for comparisons, it is a signal to the interpreter to try the r* version of a binary operator.
OTOH,
In [4]: maximum('a',1) Out[4]: NotImplemented
Which is still a problem. I think no ufunc should return NotImplemented, it should be reserved to methods so the interpreter will handle it correctly.
Chuck
NumPyDiscussion mailing list NumPyDiscussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpydiscussion
participants (3)

Charles R Harris

josef.pktd＠gmail.com

Pauli Virtanen