Return a new sequence containing the items in `seq` plus any items in
    `more` that aren't already in `seq`, preserving the order of both.
554867
def extend_unique(seq, more):
    
    seen = set(seq)
    new = []
    for item in more:
        if item not in seen:
            seen.add(item)
            new.append(item)

    return seq + type(seq)(new)
1244931
def __remove_duplicates(self, _other):
        """"""
        if not isinstance(_other, type(self)) \
           and not isinstance(_other, type(list)) \
           and not isinstance(_other, type([])):
            other = [_other]
        else:
            other = list(_other)

        # remove items already in self
        newother = []
        for i in range(0, len(other)):
            item = other.pop(0)
            if not list.__contains__(self, item):
                newother.append(item)

        # remove duplicate items in other
        other = []
        if newother != []:
            other.append(newother[0])
            for i in range(1, len(newother)):
                item = newother.pop()
                if not other.__contains__(item):
                    other.append(item)
        return other
329380
def filter_sequences(self, seq_type):
        
        return DictList(x for x in self.sequences if isinstance(x, seq_type))
278669
function map(seq, pred, ctx) {
        return sequencep(seq)?  __map.call(seq, pred, ctx)
             : /* non-seq */    []
    }
736528
def _add_sequence(self, sequence):
        
        if sequence.identity not in self._sequences.keys():
            self._sequences[sequence.identity] = sequence
        else:
            raise ValueError("{} has already been defined".format(sequence.identity))
834360
def sequence(*es):
    
    def match_sequence(s, grm=None, pos=0):
        data = []
        start = pos
        for e in es:
            s, obj, span = e(s, grm, pos)
            pos = span[1]
            if obj is not Ignore:
                data.append(obj)
        return PegreResult(s, data, (start, pos))
    return match_sequence
477124
def _get_seq_no(self, content_related):
        
        if content_related:
            result = self._sequence * 2 + 1
            self._sequence += 1
            return result
        else:
            return self._sequence * 2
963828
def normalizeSequence(sequence, considerDimensions=None):
  
  seq = np.array(sequence).astype('float64')
  nSampleDim = seq.shape[1]

  if considerDimensions is None:
    considerDimensions = range(nSampleDim)

  for dim in considerDimensions:
    seq[:, dim] = (seq[:, dim] - np.mean(seq[:, dim])) / np.std(seq[:, dim])

  sequence = seq.tolist()
  return sequence
1056883
public static ObjectSequence<TimeSeriesCollection> fixSequence(ObjectSequence<TimeSeriesCollection> seq) {
        seq = seq.sort();  // Does nothing if already sorted.

        if (!seq.isDistinct() && !seq.isEmpty()) {
            List<ObjectSequence<TimeSeriesCollection>> toConcat = new ArrayList<>();
            int lastGoodIdx = 0;
            int curIdx = 0;

            while (curIdx < seq.size()) {
                final TimeSeriesCollection curElem = seq.get(curIdx);

                // Find first item with different timestamp.
                int nextIdx = curIdx + 1;
                while (nextIdx < seq.size()
                        && curElem.getTimestamp().equals(seq.get(nextIdx).getTimestamp())) {
                    ++nextIdx;
                }

                // If more than 1 adjecent element share timestamp, merge them together.
                if (curIdx + 1 < nextIdx) {
                    toConcat.add(seq.limit(curIdx).skip(lastGoodIdx));

                    TimeSeriesCollection replacement = new LazyMergedTSC(seq.limit(nextIdx).skip(curIdx));
                    toConcat.add(ObjectSequence.of(true, true, true, replacement));
                    lastGoodIdx = curIdx = nextIdx;
                } else {
                    // Advance curIdx.
                    ++curIdx;
                }
            }

            if (lastGoodIdx < curIdx)
                toConcat.add(seq.skip(lastGoodIdx));
            seq = ObjectSequence.concat(toConcat, true, true);
        }

        return seq;
    }
1203805
def set_seqs(self, a, b):
        """"""
        self.set_seq1(a)
        self.set_seq2(b)
        self._reset_object()
36388
def match(self, seq, **kwargs):
        '''
        '''
        strict = kwargs.get('strict', False)
        top_level = kwargs.get('top_level', True)
        match = kwargs.get('match', list())

        if top_level:
            kwargs['top_level'] = False
            kwargs['match'] = match

            try:
                seq = IterableList(seq)
                self.match(seq, **kwargs)

                if strict:
                    if not seq.empty():
                        raise MatchFailed('Sequence is too long', seq)

            except MatchFailed as e:
                return e.failure()

            return Match(*match)

        for elem in self.elems:
            elem.match(seq, **kwargs)
470500
def delete_duplicates(seq):
    
    seen = set()
    seen_add = seen.add
    return [x for x in seq if not (x in seen or seen_add(x))]
588185
def _shuffled(seq):
    """"""
    fixed_random = random.Random()
    if six.PY2:  # pragma: no cover (py2)
        fixed_random.seed(FIXED_RANDOM_SEED)
    else:  # pragma: no cover (py3)
        fixed_random.seed(FIXED_RANDOM_SEED, version=1)

    seq = list(seq)
    random.shuffle(seq, random=fixed_random.random)
    return seq
278270
def pairwise(seq):
    
    for i in range(0, len(seq) - 1):
        yield (seq[i], seq[i + 1])
68499
def duplicate(self):
        """"""
        other = Matcher(self.loc, self.check_var, self.checkdefs, self.names, self.var_index)
        other.insert_check(0, "not " + self.check_var)
        self.others.append(other)
        return other
821694
def unique(seq):
    """"""
    cleaned = []
    for each in seq:
        if each not in cleaned:
            cleaned.append(each)
    return cleaned
495231
def including(self, sequence) -> Generator:
        """"""
        return (element for element in sequence
                if self.indexer(element) in self.predicates)