Starts the search or gives previously calculated sequence.

        Returns:
            The linear qubit sequence found.
485521
def get_or_search(self) -> List[GridQubit]:
        
        if not self._sequence:
            self._sequence = self._find_sequence()
        return self._sequence
1001719
private int findSlotBefore(SearchKey searchKey) {
		/*
		 * int slot = 0; while (slot < contents.getNumRecords() &&
		 * getKey(contents, slot).compareTo(searchKey) < 0) slot++; return slot
		 * - 1;
		 */
		// Optimization: Use binary search rather than sequential search
		int startSlot = 0, endSlot = currentPage.getNumRecords() - 1;
		int middleSlot = (startSlot + endSlot) / 2;

		if (endSlot >= 0) {
			while (middleSlot != startSlot) {
				if (getKey(currentPage, middleSlot, keyType.length())
						.compareTo(searchKey) < 0)
					startSlot = middleSlot;
				else
					endSlot = middleSlot;

				middleSlot = (startSlot + endSlot) / 2;
			}

			if (getKey(currentPage, endSlot, keyType.length()).compareTo(searchKey) < 0)
				return endSlot;
			else if (getKey(currentPage, startSlot, keyType.length())
					.compareTo(searchKey) < 0)
				return startSlot;
			else
				return startSlot - 1;
		} else
			return -1;
	}
955793
def locate(self, pattern):
        '''

        '''
        if len(pattern) > len(self):
            raise ValueError('Search pattern longer than searchable ' +
                             'sequence.')
        seq = self.seq

        pattern = str(pattern).upper()
        re_pattern = '(?=' + pattern + ')'
        matches = [index.start() % len(self) for index in
                   re.finditer(re_pattern, seq)]

        return matches
821737
def first(self):
        
        results = self.rpc_model.search_read(
            self.domain, None, 1, self._order_by, self.fields,
            context=self.context
        )
        return results and results[0] or None
771285
def start(self):
		
		if self._values[0] is NOT_SET:
			try:
				return self._keys[1]
			except IndexError:
				# This is empty or everything is mapped to a single value
				return None
		else:
			# This is unbounded to the left
			return self._keys[0]
573808
def qubit_pairs_to_qubit_order(
    qubit_pairs: Sequence[Sequence[ops.Qid]]
    ) -> List[ops.Qid]:
    

    if set(len(qubit_pair) for qubit_pair in qubit_pairs) != set((2,)):
        raise ValueError(
            'set(len(qubit_pair) for qubit_pair in qubit_pairs) != '
            'set((2,))')
    n_pairs = len(qubit_pairs)
    qubits = [] # type: List[ops.Qid]
    for i in range(0, 2 * (n_pairs // 2), 2):
        qubits += [qubit_pairs[i][0], qubit_pairs[i + 1][0],
                   qubit_pairs[i][1], qubit_pairs[i + 1][1]]
    if n_pairs % 2:
        qubits += list(qubit_pairs[-1])
    return qubits
1351452
def find_start_point(self):
        
        for i, row in enumerate(self.data):
            for j, _ in enumerate(row):
                if self.data[i, j] != 0:  # or not np.isfinite(self.data[i,j]):
                    return i, j
1267194
def next(self):
        
        if self._orderByPQ.size() > 0:
            
            targetRangeExContext = self._orderByPQ.pop()
            res = next(targetRangeExContext)
            
            try:
                """TODO: we can also use more_itertools.peekable to be more python friendly"""
                targetRangeExContext.peek()
                self._orderByPQ.push(targetRangeExContext)

            except StopIteration:
                pass
                
            return res
        raise StopIteration
355791
def set_sequence_from_str(self, sequence):
        
        self._qsequences = [QKeySequence(s) for s in sequence.split(', ')]
        self.update_warning()
1005760
def find(self, start, end, chrom=None):
        """"""
        intervals = self.intervals[chrom]
        ilen = len(intervals)
        # NOTE: we only search for starts, since any feature that starts within max_len of
        # the query could overlap, we must subtract max_len from the start to get the needed
        # search space. everything else proceeds like a binary search.
        # (but add distance calc for candidates).
        if not chrom in self.max_len: return []
        ileft  = binsearch_left_start(intervals, start - self.max_len[chrom], 0, ilen)
        iright = binsearch_right_end(intervals, end, ileft, ilen)
        query = Feature(start, end)
        # we have to check the distance to make sure we didnt pick up anything 
        # that started within max_len, but wasnt as long as max_len
        return [f for f in intervals[ileft:iright] if distance(f, query) == 0]
1290013
def as_qubit_order(val: 'qubit_order_or_list.QubitOrderOrList'
                       ) -> 'QubitOrder':
        
        if isinstance(val, collections.Iterable):
            return QubitOrder.explicit(val)
        if isinstance(val, QubitOrder):
            return val
        raise ValueError(
            "Don't know how to interpret <{}> as a Basis.".format(val))
361978
def next(self):
        
        step = self.raw.get('max_results', 1000)
        start = self.raw.get('start_index', 1) + step
        self.raw['start_index'] = start
        return self
758405
def first(self):
        
        pairs = self.resolve()
        try:
            return iter_first(pairs)
        except ValueError:
            raise NotFoundError(u"{0} not found".format(self.name))
392257
def readline(self, limit=-1):
        

        if not self._universal and limit < 0:
            # Shortcut common case - newline found in buffer.
            i = self._readbuffer.find(b'\n', self._offset) + 1
            if i > 0:
                line = self._readbuffer[self._offset: i]
                self._offset = i
                return line

        if not self._universal:
            return io.BufferedIOBase.readline(self, limit)

        line = b''
        while limit < 0 or len(line) < limit:
            readahead = self.peek(2)
            if readahead == b'':
                return line

            #
            # Search for universal newlines or line chunks.
            #
            # The pattern returns either a line chunk or a newline, but not
            # both. Combined with peek(2), we are assured that the sequence
            # '\r\n' is always retrieved completely and never split into
            # separate newlines - '\r', '\n' due to coincidental readaheads.
            #
            match = self.PATTERN.search(readahead)
            newline = match.group('newline')
            if newline is not None:
                if self.newlines is None:
                    self.newlines = []
                if newline not in self.newlines:
                    self.newlines.append(newline)
                self._offset += len(newline)
                return line + b'\n'

            chunk = match.group('chunk')
            if limit >= 0:
                chunk = chunk[: limit - len(line)]

            self._offset += len(chunk)
            line += chunk

        return line
239015
def get_initial_state(self, source_length: mx.sym.Symbol, source_seq_len: int) -> AttentionState:
        
        dynamic_source = mx.sym.reshape(mx.sym.zeros_like(source_length), shape=(-1, 1, 1))
        # dynamic_source: (batch_size, source_seq_len, num_hidden_dynamic_source)
        dynamic_source = mx.sym.broadcast_to(dynamic_source, shape=(0, source_seq_len, self.dynamic_source_num_hidden))
        return AttentionState(context=None, probs=None, dynamic_source=dynamic_source)
451601
def _kmp_search_first(self, pInput_sequence, pPattern):
                """"""
                input_sequence, pattern = pInput_sequence, [len(bin(e)) for e in pPattern]
                n, m = len(input_sequence), len(pattern)
                d = p = 0
                next = self._kmp_construct_next(pattern)
                while d < n and p < m:
                        p = next[len(bin(input_sequence[d]))][p]
                        d += 1
                if p == m: return d - p
                else: return -1
604848
def locate(self, pattern):
        '''

        '''
        if self.circular:
            if len(pattern) >= 2 * len(self):
                raise ValueError('Search pattern longer than searchable ' +
                                 'sequence.')
            seq = self + self[:len(pattern) - 1]
            return super(NucleicAcid, seq).locate(pattern)
        else:
            return super(NucleicAcid, self).locate(pattern)