def _newRepresentationOK(self, newRep, newIndex):
if newRep.size != self.w:<EOL><INDENT>return False<EOL><DEDENT>if (newIndex < self.minIndex-<NUM_LIT:1>) or (newIndex > self.maxIndex+<NUM_LIT:1>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>newRepBinary = numpy.array([False]*self.n)<EOL>newRepBinary[newRep] = True<EOL>midIdx = self._maxBuckets/<NUM_LIT:2><EOL>runningOverlap = self._countOverlap(self.bucketMap[self.minIndex], newRep)<EOL>if not self._overlapOK(self.minIndex, newIndex, overlap=runningOverlap):<EOL><INDENT>return False<EOL><DEDENT>for i in range(self.minIndex+<NUM_LIT:1>, midIdx+<NUM_LIT:1>):<EOL><INDENT>newBit = (i-<NUM_LIT:1>)%self.w<EOL>if newRepBinary[self.bucketMap[i-<NUM_LIT:1>][newBit]]:<EOL><INDENT>runningOverlap -= <NUM_LIT:1><EOL><DEDENT>if newRepBinary[self.bucketMap[i][newBit]]:<EOL><INDENT>runningOverlap += <NUM_LIT:1><EOL><DEDENT>if not self._overlapOK(i, newIndex, overlap=runningOverlap):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>for i in range(midIdx+<NUM_LIT:1>, self.maxIndex+<NUM_LIT:1>):<EOL><INDENT>newBit = i%self.w<EOL>if newRepBinary[self.bucketMap[i-<NUM_LIT:1>][newBit]]:<EOL><INDENT>runningOverlap -= <NUM_LIT:1><EOL><DEDENT>if newRepBinary[self.bucketMap[i][newBit]]:<EOL><INDENT>runningOverlap += <NUM_LIT:1><EOL><DEDENT>if not self._overlapOK(i, newIndex, overlap=runningOverlap):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL>
Return True if this new candidate representation satisfies all our overlap
rules. Since we know that neighboring representations differ by at most
one bit, we compute running overlaps.