timeseries

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Second = Duration(1)
	Minute = Second * 60
	Hour   = Minute * 60
	Day    = Hour * 24
	Month  = Day * 30
)

Variables

View Source
var NaN = float32(math.NaN())

Functions

func Any

func Any(t Time, v1, v2 float32) float32

func Defined

func Defined(t Time, v float32) float32

func IsInf

func IsInf(f float32, sign int) bool

func IsNaN

func IsNaN(v float32) bool

func LastNotNaN

func LastNotNaN(t Time, v1, v2 float32) float32

func Max

func Max(t Time, max, v float32) float32

func Min

func Min(t Time, min, v float32) float32

func NanCount added in v0.22.0

func NanCount(t Time, count, v float32) float32

func NanSum

func NanSum(t Time, sum, v float32) float32

func NanToZero

func NanToZero(t Time, v float32) float32

func ZeroToNan added in v0.18.2

func ZeroToNan(t Time, v float32) float32

Types

type Aggregate

type Aggregate struct {
	// contains filtered or unexported fields
}

func NewAggregate

func NewAggregate(f F) *Aggregate

func (*Aggregate) Add

func (a *Aggregate) Add(tss ...*TimeSeries) *Aggregate

func (*Aggregate) Get

func (a *Aggregate) Get() *TimeSeries

func (*Aggregate) IsEmpty

func (a *Aggregate) IsEmpty() bool

func (*Aggregate) MarshalJSON

func (a *Aggregate) MarshalJSON() ([]byte, error)

func (*Aggregate) Reduce

func (a *Aggregate) Reduce(f F) float32

type Context

type Context struct {
	From Time     `json:"from"`
	To   Time     `json:"to"`
	Step Duration `json:"step"`
}

type Duration

type Duration int64

func Since

func Since(t Time) Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) ToStandard

func (d Duration) ToStandard() time.Duration

func (Duration) Truncate

func (d Duration) Truncate(m Duration) Duration

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type F

type F func(Time, float32, float32) float32

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func (*Iterator) Next

func (i *Iterator) Next() bool

func (*Iterator) Value

func (i *Iterator) Value() (Time, float32)

type LinearRegression

type LinearRegression struct {
	// contains filtered or unexported fields
}

func NewLinearRegression

func NewLinearRegression(ts *TimeSeries) *LinearRegression

func (*LinearRegression) Calc

func (lr *LinearRegression) Calc(t Time) float32

type Time

type Time int64

func Now

func Now() Time

func (Time) Add

func (t Time) Add(d Duration) Time

func (Time) After

func (t Time) After(other Time) bool

func (Time) Before

func (t Time) Before(other Time) bool

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) String

func (t Time) String() string

func (Time) Sub

func (t Time) Sub(other Time) Duration

func (Time) ToStandard

func (t Time) ToStandard() time.Time

func (Time) Truncate

func (t Time) Truncate(d Duration) Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TimeSeries

type TimeSeries struct {
	// contains filtered or unexported fields
}

func Aggregate2

func Aggregate2(x, y *TimeSeries, f func(x, y float32) float32) *TimeSeries

func Div

func Div(x, y *TimeSeries) *TimeSeries

func Increase

func Increase(x, status *TimeSeries) *TimeSeries

func Mul

func Mul(x, y *TimeSeries) *TimeSeries

func New

func New(from Time, pointsCount int, step Duration) *TimeSeries

func NewWithData

func NewWithData(from Time, step Duration, data []float32) *TimeSeries

func Sub

func Sub(x, y *TimeSeries) *TimeSeries

func Sum

func Sum(x, y *TimeSeries) *TimeSeries

func (*TimeSeries) Fill

func (ts *TimeSeries) Fill(from Time, step Duration, data []float32) bool

func (*TimeSeries) Get

func (ts *TimeSeries) Get() *TimeSeries

func (*TimeSeries) IsEmpty

func (ts *TimeSeries) IsEmpty() bool

func (*TimeSeries) Iter

func (ts *TimeSeries) Iter() *Iterator

func (*TimeSeries) IterFrom added in v0.22.0

func (ts *TimeSeries) IterFrom(from Time) *Iterator

func (*TimeSeries) Last

func (ts *TimeSeries) Last() float32

func (*TimeSeries) LastNotNull

func (ts *TimeSeries) LastNotNull() (Time, float32)

func (*TimeSeries) Len

func (ts *TimeSeries) Len() int

func (*TimeSeries) Map

func (ts *TimeSeries) Map(f func(t Time, v float32) float32) *TimeSeries

func (*TimeSeries) MapInPlace added in v0.22.0

func (ts *TimeSeries) MapInPlace(f func(t Time, v float32) float32) *TimeSeries

func (*TimeSeries) MarshalJSON

func (ts *TimeSeries) MarshalJSON() ([]byte, error)

func (*TimeSeries) NewWithData added in v0.17.12

func (ts *TimeSeries) NewWithData(data []float32) *TimeSeries

func (*TimeSeries) Reduce

func (ts *TimeSeries) Reduce(f F) float32

func (*TimeSeries) Set

func (ts *TimeSeries) Set(t Time, v float32)

func (*TimeSeries) String

func (ts *TimeSeries) String() string

func (*TimeSeries) TailIsEmpty added in v0.22.0

func (ts *TimeSeries) TailIsEmpty() bool

func (*TimeSeries) WithNewValue

func (ts *TimeSeries) WithNewValue(newValue float32) *TimeSeries

type Value

type Value float32

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

func (Value) String

func (v Value) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL