[NumPy-Tickets] [NumPy] #1398: augmented assignment statements do not handle exceptions in object.__float__() correctly
NumPy Trac
numpy-tickets@scipy....
Sat Feb 13 06:13:41 CST 2010
#1398: augmented assignment statements do not handle exceptions in
object.__float__() correctly
----------------------------------------+-----------------------------------
Reporter: sebastian.walter@… | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: numpy.core | Version: devel
Keywords: |
----------------------------------------+-----------------------------------
Best explained at an example:
{{{
import numpy
print 'numpy.__version__ = ',numpy.__version__
class adouble:
def __init__(self,x):
self.x = x
def __mul__(self,other):
if not isinstance(other, self.__class__):
return self.__class__(self.x * other)
return self.__class__(self.x * other.x)
def __rmul__(self,other):
return self * other
def __float__(self):
raise Exception('this is not possible')
def __str__(self):
return str(self.x)
x = numpy.array([adouble(1.), adouble(2.), adouble(3.)])
y = numpy.array([4.,5.,6.])
# this should call the __float__ method of adouble which would raise an
Exception
# but it does not!
y *= x
}}}
Output:
{{{
b45ch1@shlp:~/workspace/numpy_bugs$ python
bug_casting_from_object_to_dtype_issue.py
numpy.__version__ = 1.5.0.dev
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1398>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list