<commit_before>package gopx

import (
	"errors"
	"fmt"
)

// SplitAfterKM split a track into parts of n KM
func (gpx *Gpx) SplitAfterKM(km float64) ([]*Gpx, error) {
	if km <= 0 {
		return nil, errors.New("km is less than or zero")
	}

	points := gpx.GetPoints()
	if len(points) == 0 {
		return nil, errors.New("No points found. Unable to split track")
	}

	var newGpxs []*Gpx

	var gpxPoints Points
	prev := points[0]
	gpxDist := 0.0
	gpxPoints = append(gpxPoints, prev)
	for i, point := range points[1:] {
		gpxPoints = append(gpxPoints, point)
		gpxDist = gpxDist + prev.Distance(point)
		prev = point

		if gpxDist >= km {
			name := fmt.Sprintf("%s-%d", gpx.GetName(), i)
			newGpxs = append(newGpxs, gpxPoints.createGpx(name))

			gpxPoints = gpxPoints[0:]
			gpxDist = 0.0
		}
	}

	// Remaining points
	newGpxs = append(newGpxs, gpxPoints.createGpx(""))

	return newGpxs, nil
}

// Split a Gpx track into even parts
func (gpx *Gpx) Split(parts int) ([]*Gpx, error) {
	if parts <= 0 {<commit_msg>Clearing slice with nil<commit_after>package gopx

import (
	"errors"
	"fmt"
)

// SplitAfterKM split a track into parts of n KM
func (gpx *Gpx) SplitAfterKM(km float64) ([]*Gpx, error) {
	if km <= 0 {
		return nil, errors.New("km is less than or zero")
	}

	points := gpx.GetPoints()
	if len(points) == 0 {
		return nil, errors.New("No points found. Unable to split track")
	}

	var newGpxs []*Gpx

	var gpxPoints Points
	prev := points[0]
	gpxDist := 0.0
	gpxPoints = append(gpxPoints, prev)
	for i, point := range points[1:] {
		gpxPoints = append(gpxPoints, point)
		gpxDist = gpxDist + prev.Distance(point)
		prev = point

		if gpxDist >= km {
			name := fmt.Sprintf("%s-%d", gpx.GetName(), i)
			newGpxs = append(newGpxs, gpxPoints.createGpx(name))

			gpxPoints = nil
			gpxDist = 0.0
		}
	}

	// Remaining points
	newGpxs = append(newGpxs, gpxPoints.createGpx(""))

	return newGpxs, nil
}

// Split a Gpx track into even parts
func (gpx *Gpx) Split(parts int) ([]*Gpx, error) {
	if parts <= 0 {
{'fraction_non_alphanumeric': 0.14321357285429143, 'fraction_numerical': 0.011477045908183632, 'mean_word_length': 3.577625570776256, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '993590', 'n_tokens_mistral': 862, 'n_tokens_neox': 783, 'n_words': 225}