Take the first n elements of the sequence.

        >>> seq([1, 2, 3, 4]).take(2)
        [1, 2]

        :param n: number of elements to take
        :return: first n elements of sequence
351094
def take(self, n):
        
        if n <= 0:
            return self._transform(transformations.take_t(0))
        else:
            return self._transform(transformations.take_t(n))
1298646
def array(self,n=-1):
        
        if n is None:
            return np.array(self.list)
        return np.array(self.list)[n]
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
958901
def randchoice(seq: Union[str, list, tuple, dict, set]) -> any:
    
    if not isinstance(seq, (str, list, tuple, dict, set)):
        raise TypeError('seq must be str, list, tuple, dict or set')
    if len(seq) <= 0:
        raise IndexError('seq must have at least one element')

    if isinstance(seq, set):
        values = list(seq)
        return randchoice(values)
    elif isinstance(seq, dict):
        indexes = list(seq)
        index = randchoice(indexes)
    else:
        index = randbelow(len(seq))

    return seq[index]
592337
def subseq(self, start_offset=0, end_offset=None):
        
        from sebastian.core import DURATION_64

        def subseq_iter(start_offset, end_offset):
            cur_offset = 0
            for point in self._elements:
                try:
                    cur_offset += point[DURATION_64]
                except KeyError:
                    raise ValueError("HSeq.subseq requires all points to have a %s attribute" % DURATION_64)
                #Skip until start
                if cur_offset < start_offset:
                    continue

                #Yield points start_offset <=  point < end_offset
                if end_offset is None or cur_offset < end_offset:
                    yield point
                else:
                    raise StopIteration
        return HSeq(subseq_iter(start_offset, end_offset))
181418
def Take(self: Iterable, n):
    

    for i, e in enumerate(self):
        if i == n:
            break
        yield e
199232
def normalizeSequence(sequence):
  
  seq = np.array(sequence).astype('float64')

  meanSeq = np.mean(seq)
  stdSeq = np.std(seq)
  seq = (seq - np.mean(seq)) / np.std(seq)

  sequence = seq.tolist()
  return sequence, meanSeq, stdSeq
757764
def _chunks(self, l, n):
        
        l.sort()
        newn = int(1.0 * len(l) / n + 0.5)
        for i in range(0, n-1):
            yield l[i*newn:i*newn+newn]
        yield l[n*newn-newn:]
993530
function seq() {
        var rules = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            rules[_i - 0] = arguments[_i];
        }
        var rs = rules.map(RuleTypeToRule);
        if (rs.length == 0)
            throw new Error("At least one rule is expected when calling `seq`");
        if (rs.length == 1)
            return rs[0];
        var rule1 = rs[0];
        var rule2 = seq.apply(void 0, rs.slice(1));
        if (rule1.nonAdvancing && rule2 instanceof Advance)
            return new AdvanceIf(rule1);
        else
            return new Sequence(rule1, rule2);
    }
470397
def pull(iterable, n):
    
    fifo = collections.deque(maxlen=n)
    for i in iterable:
        fifo.append(i)
    return list(fifo)
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))
1221436
def subseq(start_offset=0, end_offset=None):
    
    def _(sequence):
        return sequence.subseq(start_offset, end_offset)
    return _
1203383
def split_sequence(seq, n):
    """"""
    tokens = []
    while seq:
        tokens.append(seq[:n])
        seq = seq[n:]
    return tokens
148270
def n_elements(self):
        
        if self.is_array:
            return functools.reduce(operator.mul, self.array_dimensions)
        else:
            return 1
42391
def _to_seq(sc, cols, converter=None):
    
    if converter:
        cols = [converter(c) for c in cols]
    return sc._jvm.PythonUtils.toSeq(cols)
1014048
def InputSplines(seq_length, n_bases=10, name=None, **kwargs):
    
    return Input((seq_length, n_bases), name=name, **kwargs)
1000542
def slice_sequence(self,start,end):
     
     #find the sequence length
     l = self.length
     indexstart = start
     indexend = end
     ns = []
     tot = 0
     for r in self._rngs:
        tot += r.length
        n = r.copy()
        if indexstart > r.length:  
           indexstart-=r.length
           continue
        n.start = n.start+indexstart
        if tot > end: 
           diff = tot-end
           n.end -= diff
           tot = end
        indexstart = 0
        ns.append(n)
        if tot == end: break
     if len(ns)==0: return None
     return MappingGeneric(ns,self._options)