Make a serie slice
777020
def slice(self, serie, start_angle, total):
        """"""
        serie_node = self.svg.serie(serie)
        dual = self._len > 1 and not self._order == 1

        slices = self.svg.node(serie_node['plot'], class_="slices")
        serie_angle = 0
        original_start_angle = start_angle
        if self.half_pie:
            center = ((self.width - self.margin_box.x) / 2.,
                      (self.height - self.margin_box.y) / 1.25)
        else:
            center = ((self.width - self.margin_box.x) / 2.,
                      (self.height - self.margin_box.y) / 2.)

        radius = min(center)
        for i, val in enumerate(serie.values):
            perc = val / total
            if self.half_pie:
                angle = 2 * pi * perc / 2
            else:
                angle = 2 * pi * perc
            serie_angle += angle
            val = self._format(serie, i)
            metadata = serie.metadata.get(i)
            slice_ = decorate(
                self.svg, self.svg.node(slices, class_="slice"), metadata
            )
            if dual:
                small_radius = radius * .9
                big_radius = radius
            else:
                big_radius = radius * .9
                small_radius = radius * serie.inner_radius

            alter(
                self.svg.slice(
                    serie_node, slice_, big_radius, small_radius, angle,
                    start_angle, center, val, i, metadata
                ), metadata
            )
            start_angle += angle

        if dual:
            val = self._serie_format(serie, sum(serie.values))
            self.svg.slice(
                serie_node, self.svg.node(slices,
                                          class_="big_slice"), radius * .9, 0,
                serie_angle, original_start_angle, center, val, i, metadata
            )
        return serie_angle
952669
def expand_slice(s, a, b, start=0, stop=None):
    ''''''
    n1 = max(s.start - a, start)
    n2 = s.stop + b
    if stop is not None:
        n2 = min(n2, stop)

    return slice(n1, n2, 1)
23175
def slice_to(self, s):
        '''
        
        '''
        result = ''
        if self.slice_check():
            result = self.current[self.bra:self.ket]
        return result
620370
def slice! *args
      b, l = get_beginning_and_length *args
      head, sliced, tail = ()
      sliced = l.nil? ? self.slice(b) : self.slice(b, l)
      head = self.slice(0, b)
      l = 1 if l.nil?
      tail = self.slice((b + l)..-1)
      self.clear
      self.concat head + tail
      sliced
    end
935897
def make_slice_strings(cls, slice_key):
        
        start = slice_key.start
        size = slice_key.stop - start
        return (str(start), str(size))
602285
def line(self, serie, rescale=False):
        """"""
        serie_node = self.svg.serie(serie)
        if rescale and self.secondary_series:
            points = self._rescale(serie.points)
        else:
            points = serie.points
        view_values = list(map(self.view, points))
        if serie.show_dots:
            for i, (x, y) in enumerate(view_values):
                if None in (x, y):
                    continue
                if self.logarithmic:
                    if points[i][1] is None or points[i][1] <= 0:
                        continue
                if (serie.show_only_major_dots and self.x_labels
                        and i < len(self.x_labels)
                        and self.x_labels[i] not in self._x_labels_major):
                    continue

                metadata = serie.metadata.get(i)
                classes = []
                if x > self.view.width / 2:
                    classes.append('left')
                if y > self.view.height / 2:
                    classes.append('top')
                classes = ' '.join(classes)

                self._confidence_interval(
                    serie_node['overlay'], x, y, serie.values[i], metadata
                )

                dots = decorate(
                    self.svg,
                    self.svg.node(serie_node['overlay'], class_="dots"),
                    metadata
                )

                val = self._format(serie, i)
                alter(
                    self.svg.transposable_node(
                        dots,
                        'circle',
                        cx=x,
                        cy=y,
                        r=serie.dots_size,
                        class_='dot reactive tooltip-trigger'
                    ), metadata
                )
                self._tooltip_data(
                    dots, val, x, y, xlabel=self._get_x_label(i)
                )
                self._static_value(
                    serie_node, val, x + self.style.value_font_size,
                    y + self.style.value_font_size, metadata
                )

        if serie.stroke:
            if self.interpolate:
                points = serie.interpolated
                if rescale and self.secondary_series:
                    points = self._rescale(points)
                view_values = list(map(self.view, points))
            if serie.fill:
                view_values = self._fill(view_values)

            if serie.allow_interruptions:
                # view_values are in form [(x1, y1), (x2, y2)]. We
                # need to split that into multiple sequences if a
                # None is present here

                sequences = []
                cur_sequence = []
                for x, y in view_values:
                    if y is None and len(cur_sequence) > 0:
                        # emit current subsequence
                        sequences.append(cur_sequence)
                        cur_sequence = []
                    elif y is None:  # just discard
                        continue
                    else:
                        cur_sequence.append((x, y))  # append the element

                if len(cur_sequence) > 0:  # emit last possible sequence
                    sequences.append(cur_sequence)
            else:
                # plain vanilla rendering
                sequences = [view_values]
            if self.logarithmic:
                for seq in sequences:
                    for ele in seq[::-1]:
                        y = points[seq.index(ele)][1]
                        if y is None or y <= 0:
                            del seq[seq.index(ele)]
            for seq in sequences:
                self.svg.line(
                    serie_node['plot'],
                    seq,
                    close=self._self_close,
                    class_='line reactive' +
                    (' nofill' if not serie.fill else '')
                )
326804
def _create_slice(self, key):
        """"""

        if isinstance(key, slice):
            step = key.step
            if step is None:
                step = 1

            if step != 1:
                raise ArgumentError("You cannot slice with a step that is not equal to 1", step=key.step)

            start_address = key.start
            end_address = key.stop - 1

            start_i, start_seg = self._find_address(start_address)
            end_i, _end_seg = self._find_address(end_address)

            if start_seg is None or start_i != end_i:
                raise ArgumentError("Slice would span invalid data in memory",
                                    start_address=start_address, end_address=end_address)

            block_offset = start_address - start_seg.start_address
            block_length = end_address - start_address + 1

            return start_seg, block_offset, block_offset + block_length
        elif isinstance(key, int):
            start_i, start_seg = self._find_address(key)
            if start_seg is None:
                raise ArgumentError("Requested invalid address", address=key)

            return start_seg, key - start_seg.start_address, None
        else:
            raise ArgumentError("Unknown type of address key", address=key)
1021800
def slice(self, start=None, stop=None, step=None):
        
        check_type(start, int)
        check_type(stop, int)
        check_type(step, int)

        if step is not None and step < 0:
            raise ValueError('Only positive steps are currently supported')

        return _series_str_result(self, weld_str_slice, start=start, stop=stop, step=step)
701201
function slice(v, start, end, step) {
  var r = [];
  var i = void 0;
  if (step > 0) {
    for (i = start; i < end; i += step) {
      r.push(v[i]);
    }
  } else {
    for (i = start; i > end; i += step) {
      r.push(v[i]);
    }
  }
  return r;
}
186182
function slice() {
  for (var
    o = +this,                // offset
    i = o,                    // start index
    l = arguments.length,     // length
    n = l - o,                // new length
    a = Array(n < 0 ? 0 : n); // new Array
    i < l; i++
  ) a[i - o] = arguments[i];
  return a;
}
515310
def funnel(self, serie):
        """"""
        serie_node = self.svg.serie(serie)
        fmt = lambda x: '%f %f' % x
        for i, poly in enumerate(serie.points):
            metadata = serie.metadata.get(i)
            val = self._format(serie, i)

            funnels = decorate(
                self.svg, self.svg.node(serie_node['plot'], class_="funnels"),
                metadata
            )

            alter(
                self.svg.node(
                    funnels,
                    'polygon',
                    points=' '.join(map(fmt, map(self.view, poly))),
                    class_='funnel reactive tooltip-trigger'
                ), metadata
            )

            # Poly center from label
            x, y = self.view((
                self._center(self._x_pos[serie.index]),
                sum([point[1] for point in poly]) / len(poly)
            ))
            self._tooltip_data(
                funnels, val, x, y, 'centered', self._get_x_label(serie.index)
            )
            self._static_value(serie_node, val, x, y, metadata)
1156514
def slice(self, start, end):
        
        start, end, mask = \
            self._check_boundaries(start, end, allow_infinite=True)

        result = TimeSeries(default=self.default)
        for t0, t1, value in self.iterperiods(start, end):
            result[t0] = value

        result[t1] = self[t1]

        return result
1028789
def split(self, t):
        """"""
        bpoints1, bpoints2 = split_bezier(self.bpoints(), t)
        return CubicBezier(*bpoints1), CubicBezier(*bpoints2)
22975
def _consolidate_slices(slices):
    
    result = []
    last_slice = slice(None)
    for slice_ in slices:
        if not isinstance(slice_, slice):
            raise ValueError('list element is not a slice: %r' % slice_)
        if (result and last_slice.stop == slice_.start and
                _is_one_or_none(last_slice.step) and
                _is_one_or_none(slice_.step)):
            last_slice = slice(last_slice.start, slice_.stop, slice_.step)
            result[-1] = last_slice
        else:
            result.append(slice_)
            last_slice = slice_
    return result
326824
def split(self, tValues):
        
        if self.segmentType == "curve":
            on1 = self.previousOnCurve
            off1 = self.points[0].coordinates
            off2 = self.points[1].coordinates
            on2 = self.points[2].coordinates
            return bezierTools.splitCubicAtT(on1, off1, off2, on2, *tValues)
        elif self.segmentType == "line":
            segments = []
            x1, y1 = self.previousOnCurve
            x2, y2 = self.points[0].coordinates
            dx = x2 - x1
            dy = y2 - y1
            pp = x1, y1
            for t in tValues:
                np = (x1+dx*t, y1+dy*t)
                segments.append([pp, np])
                pp = np
            segments.append([pp, (x2, y2)])
            return segments
        elif self.segmentType == "qcurve":
            raise NotImplementedError
        else:
            raise NotImplementedError
609673
def bin_to_edge_slice(s, n):
    
    s = canonify_slice(s, n)
    start = s.start
    stop = s.stop
    if start > stop:
        _stop = start + 1
        start = stop + 1
        stop = _stop
    start = max(start - 1, 0)
    step = abs(s.step)
    if stop <= 1 or start >= n - 1 or stop == start + 1:
        return slice(0, None, min(step, n - 2))
    s = slice(start, stop, abs(s.step))
    if len(range(*s.indices(n - 1))) < 2:
        return slice(start, stop, stop - start - 1)
    return s
606206
def _serie_format(self, serie, value):
        """"""

        kwargs = {'chart': self, 'serie': serie, 'index': None}
        formatter = (serie.formatter or self.formatter or self._value_format)
        kwargs = filter_kwargs(formatter, kwargs)
        return formatter(value, **kwargs)