예제 #1
0
 def __setitem__(self, k, value):
     length = len(self)
     if length >= self.max_size or k > self.max_size:
         self.popleft()
         self.append(value)
     else:
         deque.__setitem__(self, k, value)
예제 #2
0
 def __setitem__(self, k, value):
   length = len(self)
   if length >= self.max_size or k > self.max_size:
     self.popleft()
     self.append(value)
   else:
     deque.__setitem__(self, k, value)
예제 #3
0
파일: rigid.py 프로젝트: gritslab/utility
    def __setitem__(self, key, value):
        if type(key) == slice:
            if all([F.reference == self.reference for F in value]):

                if key.start is None:
                    start = 0
                else:
                    start = key.start

                if key.stop is None:
                    stop = len(self)
                else:
                    stop = key.stop

                if key.step is None:
                    step = 1
                else:
                    step = key.step

                cnt = 0
                for ind in range(start, stop, step):
                    self[ind] = value[cnt]
                    cnt += 1

            else:
                raise Exception("Invalid argument: " + str(value) + "\n" + \
                                "Valid types: rigid.Transformation with a reference equal to\n"
                                + str(self.reference))
        else:
            if isinstance(value, Transformation) and value.reference == self.reference:
                deque.__setitem__(self, key, value)
            else:
                raise Exception("Invalid argument: " + str(value) + "\n" + \
                                "Valid types: rigid.Transformation with a reference equal to\n"
                                + str(self.reference))
예제 #4
0
 def __setitem__(self, pos, val):
     if not isinstance(val, Color):
         val = Color(*val)
     deque.__setitem__(self, pos, val)
예제 #5
0
 def __setitem__( self, key, value ):
     if self.mtx.acquire():
         values = deque.__setitem__( self, key, value )
         self.mtx.release()
예제 #6
0
 def __setitem__(self, pos, val):
     if not isinstance(val, Color):
         val = Color(*val)
     deque.__setitem__(self, pos, val)