[NumPy-Tickets] [NumPy] #1563: setitem in subclass of ndarray not working for 1D arrays
NumPy Trac
numpy-tickets@scipy....
Wed Jul 28 08:58:23 CDT 2010
#1563: setitem in subclass of ndarray not working for 1D arrays
------------------------------+---------------------------------------------
Reporter: ds | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: none
Keywords: setitem subclass |
------------------------------+---------------------------------------------
For a subclass of ndarray the setitem method is not working with tuples,
but only if the array is 1D.
{{{
from numpy import ndarray
class C(ndarray):
def __new__(cls,i):
return N.ones((i,)).view(cls)
a = C(5)
a[(0,)] = 2.
# raises: RuntimeError: Getitem not returning array.
# this would work if 'a' is a normal ndarray
# note: 'a[0] = 2.' is working
# 'b = a[(0,)]' is working
# and if the subclass is an ndarray of higher dimension then
# also e.g. (for 2D array subclass) 'a[(0,1)] = 2.' is working
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1563>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list