[Numpy-tickets] [NumPy] #1023: Subclassed ndarray fails with ValueError when assigning to a sliced array

NumPy numpy-tickets@scipy....
Sun Feb 22 21:57:42 CST 2009


#1023: Subclassed ndarray fails with ValueError when assigning to a sliced array
------------------------+---------------------------------------------------
 Reporter:  psederberg  |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  1.3.0   
Component:  Other       |     Version:  1.1     
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------
 Hi Folks:

 I've been working on a subclass of ndarray that has named dimensions that
 you can use to slice within a custom __getitem__.  For example, you can do
 something like this:

 {{{ x['time>0'] }}}

 to slice the array where the time dimension is greater than zero.

 This is all working nicely, right up until I try to assign to a slice like
 this:

 {{{ x['time>0'] += 1 }}}

 or this

 {{{ x['time>0'] = x['time>0'] + 1 }}}

 giving me the following error:

 {{{ ValueError: field named time>0 not found. }}}

 I'm not sure what is raising this error, so I'm scared it's actually in
 the interpreter or somewhere deep in the numpy code, but I figured I'd try
 here first.

 Any ideas for what's going on here?  All assignments with standard slices
 work just fine.  Is there some code in numpy that is checking the contents
 of __getitem__ and causing it to fail here?  Perhaps something having to
 do with record arrays?

 Thanks for any thoughts,
 Per

 PS-> I'm running this on NumPy 1.1.0 in Debian Lenny.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/1023>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list