<commit_before>package series

import (
	"math"
)

type SeriesPoint struct {
	name   string
	points DataPoints
	step   int
}

func NewSeriesPoint(name string, points DataPoints, step int) *SeriesPoint {
	return &SeriesPoint{
		name:   name,
		points: points.Sort().Deduplicate(),
		step:   step,
	}
}

func (s *SeriesPoint) Name() string {
	return s.name
}

func (s *SeriesPoint) Points() DataPoints {
	return s.points
}

func (s *SeriesPoint) Values() []float64 {
	points := s.Points()
	vals := make([]float64, points.Len())
	for i, _ := range vals {
		vals[i] = math.NaN() // NaN reprensents 'lack of data point'
	}
	for i, p := range points {
		if p.Timestamp() == (s.Start() + int64(s.Step()*i)) {
			vals[i] = p.Value()
		}
	}
	return vals
}

func (s *SeriesPoint) Start() int64 {
	return s.Points()[0].Timestamp()
}

func (s *SeriesPoint) End() int64 {
	return s.Start() + int64(s.Step()*(s.Len()-1))
}

func (s *SeriesPoint) Step() int {
	return s.step
}

func (s *SeriesPoint) Len() int {
	return s.Points().Len()
}

func (s *SeriesPoint) ToSeries() Series {
	return NewSeries(s.Name(), s.Values(), s.Start(), s.Step())
}<commit_msg>Add series_point.go comment<commit_after>package series

import (
	"math"
)

// SeriesPoint represents a series having not only value but DataPoints.
type SeriesPoint struct {
	name   string
	points DataPoints
	step   int
}

// NewSeriesPoint creates a new SeriesPoint. The points is sorted by the timestamp and
// deduplicated with the same timestamp.
func NewSeriesPoint(name string, points DataPoints, step int) *SeriesPoint {
	return &SeriesPoint{
		name:   name,
		points: points.Sort().Deduplicate(),
		step:   step,
	}
}

// Name returns the name.
func (s *SeriesPoint) Name() string {
	return s.name
}

// Points returns the points.
func (s *SeriesPoint) Points() DataPoints {
	return s.points
}

// Values convertes the values with []float64 format.
func (s *SeriesPoint) Values() []float64 {
	points := s.Points()
	vals := make([]float64, points.Len())
	for i, _ := range vals {
		vals[i] = math.NaN() // NaN reprensents 'lack of data point'
	}
	for i, p := range points {
		if p.Timestamp() == (s.Start() + int64(s.Step()*i)) {
			vals[i] = p.Value()
		}
	}
	return vals
}

// Start returns the unix timestamp of the beginning of the data points.
func (s *SeriesPoint) Start() int64 {
	return s.Points()[0].Timestamp()
}

// End returns the unix timestamp of the end of the data points.
func (s *SeriesPoint) End() int64 {
	return s.Start() + int64(s.Step()*(s.Len()-1))
}

// Step returns the step.
func (s *SeriesPoint) Step() int {
	return s.step
}

// Len returns the length of the points.
func (s *SeriesPoint) Len() int {
	return s.Points().Len()
}

// ToSeries converts s into Series.
func (s *SeriesPoint) ToSeries() Series {
	return NewSeries(s.Name(), s.Values(), s.Start(), s.Step())
}
{'fraction_non_alphanumeric': 0.1523876404494382, 'fraction_numerical': 0.010533707865168539, 'mean_word_length': 3.724709784411277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2613843', 'n_tokens_mistral': 1029, 'n_tokens_neox': 989, 'n_words': 319}