parameters: (self, indx, value)
return_statement: return
docstring: x.__setitem__(i, y) <==> x[i]=y
  
          Set item described by index. If value is masked, masks those
          locations.
docstring_summary: x.__setitem__(i, y) <==> x[i]=y
docstring_tokens: x . __setitem__ ( i y ) < == > x [ i ] = y
function: def __setitem__(self, indx, value):
          """x.__setitem__(i, y) <==> x[i]=y
  
          Set item described by index. If value is masked, masks those
          locations.
  
          """
          if self is masked:
              raise MaskError, 'Cannot alter the masked element.'
          # This test is useful, but we should keep things light...
  #        if getmask(indx) is not nomask:
  #            msg = "Masked arrays must be filled before they can be used as indices!"
  #            raise IndexError, msg
          _data = ndarray.view(self, ndarray.__getattribute__(self, '_baseclass'))
          _mask = ndarray.__getattribute__(self, '_mask')
          if isinstance(indx, basestring):
              ndarray.__setitem__(_data, indx, value)
              if _mask is nomask:
                  self._mask = _mask = make_mask_none(self.shape, self.dtype)
              _mask[indx] = getmask(value)
              return
          #........................................
          _dtype = ndarray.__getattribute__(_data, 'dtype')
          nbfields = len(_dtype.names or ())
          #........................................
          if value is masked:
              # The mask wasn't set: create a full version...
              if _mask is nomask:
                  _mask = self._mask = make_mask_none(self.shape, _dtype)
              # Now, set the mask to its value.
              if nbfields:
                  _mask[indx] = tuple([True] * nbfields)
              else:
                  _mask[indx] = True
              if not self._isfield:
                  self._sharedmask = False
              return
          #........................................
          # Get the _data part of the new value
          dval = value
          # Get the _mask part of the new value
          mval = getattr(value, '_mask', nomask)
          if nbfields and mval is nomask:
              mval = tuple([False] * nbfields)
          if _mask is nomask:
              # Set the data, then the mask
              ndarray.__setitem__(_data, indx, dval)
              if mval is not nomask:
                  _mask = self._mask = make_mask_none(self.shape, _dtype)
                  ndarray.__setitem__(_mask, indx, mval)
          elif not self._hardmask:
              # Unshare the mask if necessary to avoid propagation
              if not self._isfield:
                  self.unshare_mask()
                  _mask = ndarray.__getattribute__(self, '_mask')
              # Set the data, then the mask
              ndarray.__setitem__(_data, indx, dval)
              ndarray.__setitem__(_mask, indx, mval)
          elif hasattr(indx, 'dtype') and (indx.dtype == MaskType):
              indx = indx * umath.logical_not(_mask)
              ndarray.__setitem__(_data, indx, dval)
          else:
              if nbfields:
                  err_msg = "Flexible 'hard' masks are not yet supported..."
                  raise NotImplementedError(err_msg)
              mindx = mask_or(_mask[indx], mval, copy=True)
              dindx = self._data[indx]
              if dindx.size > 1:
                  dindx[~mindx] = dval
              elif mindx is nomask:
                  dindx = dval
              ndarray.__setitem__(_data, indx, dindx)
              _mask[indx] = mindx
          return
function_tokens: def __setitem__ ( self , indx , value ) : if self is masked : raise MaskError , 'Cannot alter the masked element.' # This test is useful, but we should keep things light... #        if getmask(indx) is not nomask: #            msg = "Masked arrays must be filled before they can be used as indices!" #            raise IndexError, msg _data = ndarray . view ( self , ndarray . __getattribute__ ( self , '_baseclass' ) ) _mask = ndarray . __getattribute__ ( self , '_mask' ) if isinstance ( indx , basestring ) : ndarray . __setitem__ ( _data , indx , value ) if _mask is nomask : self . _mask = _mask = make_mask_none ( self . shape , self . dtype ) _mask [ indx ] = getmask ( value ) return #........................................ _dtype = ndarray . __getattribute__ ( _data , 'dtype' ) nbfields = len ( _dtype . names or ( ) ) #........................................ if value is masked : # The mask wasn't set: create a full version... if _mask is nomask : _mask = self . _mask = make_mask_none ( self . shape , _dtype ) # Now, set the mask to its value. if nbfields : _mask [ indx ] = tuple ( [ True ] * nbfields ) else : _mask [ indx ] = True if not self . _isfield : self . _sharedmask = False return #........................................ # Get the _data part of the new value dval = value # Get the _mask part of the new value mval = getattr ( value , '_mask' , nomask ) if nbfields and mval is nomask : mval = tuple ( [ False ] * nbfields ) if _mask is nomask : # Set the data, then the mask ndarray . __setitem__ ( _data , indx , dval ) if mval is not nomask : _mask = self . _mask = make_mask_none ( self . shape , _dtype ) ndarray . __setitem__ ( _mask , indx , mval ) elif not self . _hardmask : # Unshare the mask if necessary to avoid propagation if not self . _isfield : self . unshare_mask ( ) _mask = ndarray . __getattribute__ ( self , '_mask' ) # Set the data, then the mask ndarray . __setitem__ ( _data , indx , dval ) ndarray . __setitem__ ( _mask , indx , mval ) elif hasattr ( indx , 'dtype' ) and ( indx . dtype == MaskType ) : indx = indx * umath . logical_not ( _mask ) ndarray . __setitem__ ( _data , indx , dval ) else : if nbfields : err_msg = "Flexible 'hard' masks are not yet supported..." raise NotImplementedError ( err_msg ) mindx = mask_or ( _mask [ indx ] , mval , copy = True ) dindx = self . _data [ indx ] if dindx . size > 1 : dindx [ ~ mindx ] = dval elif mindx is nomask : dindx = dval ndarray . __setitem__ ( _data , indx , dindx ) _mask [ indx ] = mindx return