Ejemplo n.º 1
0
 def descr_setitem(self, space, w_idx, w_value):
     if not (space.isinstance_w(w_idx, space.w_int) or
             space.isinstance_w(w_idx, space.w_slice)):
         raise oefmt(space.w_IndexError, 'unsupported iterator index')
     base = self.base
     start, stop, step, length = space.decode_index4(w_idx, base.get_size())
     arr = convert_to_array(space, w_value)
     loop.flatiter_setitem(space, self.base, arr, start, step, length)
Ejemplo n.º 2
0
 def descr_setitem(self, space, w_idx, w_value):
     if not (space.isinstance_w(w_idx, space.w_int) or
         space.isinstance_w(w_idx, space.w_slice)):
         raise OperationError(space.w_IndexError,
                              space.wrap('unsupported iterator index'))
     base = self.base
     start, stop, step, length = space.decode_index4(w_idx, base.get_size())
     arr = convert_to_array(space, w_value)
     loop.flatiter_setitem(space, self.base, arr, start, step, length)
Ejemplo n.º 3
0
 def descr_setitem(self, space, w_idx, w_value):
     if not (space.isinstance_w(w_idx, space.w_int) or space.isinstance_w(w_idx, space.w_slice)):
         raise oefmt(space.w_IndexError, "unsupported iterator index")
     start, stop, step, length = space.decode_index4(w_idx, self.iter.size)
     try:
         state = self.iter.goto(start)
         dtype = self.base.get_dtype()
         if length == 1:
             try:
                 val = dtype.coerce(space, w_value)
             except OperationError:
                 raise oefmt(space.w_ValueError, "Error setting single item of array.")
             self.iter.setitem(state, val)
             return
         arr = convert_to_array(space, w_value)
         loop.flatiter_setitem(space, dtype, arr, self.iter, state, step, length)
     finally:
         self.iter.reset(self.state, mutate=True)
Ejemplo n.º 4
0
 def descr_setitem(self, space, w_idx, w_value):
     if not (space.isinstance_w(w_idx, space.w_int) or
             space.isinstance_w(w_idx, space.w_slice)):
         raise oefmt(space.w_IndexError, 'unsupported iterator index')
     start, stop, step, length = space.decode_index4(w_idx, self.iter.size)
     try:
         state = self.iter.goto(start)
         dtype = self.base.get_dtype()
         if length == 1:
             try:
                 val = dtype.coerce(space, w_value)
             except OperationError:
                 raise oefmt(space.w_ValueError, "Error setting single item of array.")
             self.iter.setitem(state, val)
             return
         arr = convert_to_array(space, w_value)
         loop.flatiter_setitem(space, dtype, arr, self.iter, state, step, length)
     finally:
         self.iter.reset(self.state, mutate=True)