funcs

package
v0.0.0-...-bc49051 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[Input, Output any](ctx context.Context, input Input) (Output, error)

func CastMany

func CastMany[Input, Output any](ctx context.Context, inputs ...Input) ([]Output, error)

func CastManyMerged

func CastManyMerged[Input, Output any](ctx context.Context, inputs ...[]Input) ([]Output, error)

func CurrentTimestamp

func CurrentTimestamp(_ context.Context) (time.Time, error)

CurrentTimestamp returns the current timestamp.

func CutoffEpsilon

func CutoffEpsilon[A MathScalars](_ context.Context, delta A, old, new A) (output bool, err error)

CutoffEpsilon is a simple cutoff check that does a strict comparison

func CutoffExpression

func CutoffExpression[Input any](expression string) func(context.Context, Input, Input) (bool, error)

func CutoffUnchanged

func CutoffUnchanged[A comparable](_ context.Context, old, new A) (bool, error)

CutoffUnchanged is a simple cutoff check that does a strict comparison

func Expression

func Expression[Input, Output any](expression string) func(context.Context, *incrutil.Inputs[Input]) (Output, error)

Expression returns a function that evaluates a given expression.

func FetchCSV

func FetchCSV(ctx context.Context, url string) (*types.Table, error)

FetchCSV fetches a CSV from a given url.

func FetchJSON

func FetchJSON(ctx context.Context, url, method, body string) (any, error)

FetchJSON fetches a JSON from a given url.

func FilterTableExpression

func FilterTableExpression(expression string) func(context.Context, *types.Table, *incrutil.Inputs[any]) (*types.Table, error)

FilterTableExpression applies a predicate to a table on a row by row basis.

func First

func First[T any](ctx context.Context, inputs *incrutil.Inputs[T]) (output T, err error)

func FirstMany

func FirstMany[T any](ctx context.Context, inputs *incrutil.Inputs[[]T]) (output T, err error)

func Last

func Last[T any](ctx context.Context, inputs *incrutil.Inputs[T]) (output T, err error)

func LastMany

func LastMany[T any](_ context.Context, inputs *incrutil.Inputs[[]T]) (output T, err error)

func Length

func Length[T any](ctx context.Context, input T) (int64, error)

func LengthAny

func LengthAny(input any) int

func LengthMany

func LengthMany[T any](ctx context.Context, input ...T) (output int64, err error)

func Max

func Max[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[T]) (output T, _ error)

func MaxMany

func MaxMany[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[[]T]) (output T, _ error)

func Mean

func Mean[A MathScalars](ctx context.Context, inputValues *incrutil.Inputs[A]) (output A, _ error)

func MeanMany

func MeanMany[A MathScalars](ctx context.Context, inputValues *incrutil.Inputs[[]A]) (output A, _ error)

func Median

func Median[A MathScalars](ctx context.Context, inputValues *incrutil.Inputs[A]) (output A, _ error)

func MedianMany

func MedianMany[A MathScalars](ctx context.Context, inputValues *incrutil.Inputs[[]A]) (output A, _ error)

func Merge

func Merge[T any](ctx context.Context, inputValues *incrutil.Inputs[T]) ([]T, error)

func MergeMany

func MergeMany[T any](ctx context.Context, inputValues *incrutil.Inputs[[]T]) ([]T, error)

func Min

func Min[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[T]) (output T, _ error)

func MinMany

func MinMany[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[[]T]) (output T, _ error)

func Percentile

func Percentile(percent float64) func(context.Context, *incrutil.Inputs[[]float64]) (float64, error)

func PercentileSorted

func PercentileSorted(percent float64) func(context.Context, *incrutil.Inputs[[]float64]) (float64, error)

func ReadCSV

func ReadCSV(ctx context.Context, filepath string, modTime time.Time) (output *types.Table, err error)

ReadCSV reads a csv from a given file input and returns a table.

The table values initially will be string.

func ReadFile

func ReadFile[Output any](ctx context.Context, filepath string, modTime time.Time) (output Output, err error)

func ReadFileAny

func ReadFileAny(_ context.Context, filepath string, output any) error

func ReadParquet

func ReadParquet(ctx context.Context, filepath string, modtime time.Time) (output *types.Table, err error)

func Reverse

func Reverse[T any](ctx context.Context, inputValues *incrutil.Inputs[T]) ([]T, error)

func ReverseMany

func ReverseMany[T any](ctx context.Context, inputValues *incrutil.Inputs[[]T]) ([]T, error)

func ScatterChart

func ScatterChart(config ChartConfig) func(context.Context, []float64, []float64) (types.SVG, error)

ScatterChart renders a chart to svg.

func Sort

func Sort[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[T]) ([]T, error)

func SortComparer

func SortComparer[T any](comparers ...iter.SorterComparer[T]) func(context.Context, *incrutil.Inputs[T]) ([]T, error)

func SortComparerMany

func SortComparerMany[T any](comparers ...iter.SorterComparer[T]) func(context.Context, *incrutil.Inputs[[]T]) ([]T, error)

func SortMany

func SortMany[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[[]T]) ([]T, error)

func StatFile

func StatFile(_ context.Context, filepath string) (time.Time, error)

StatFile stats a file yielding the modtime as a timestamp.

func Sum

func Sum[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[T]) (output T, _ error)

func SumMany

func SumMany[T cmp.Ordered](ctx context.Context, inputValues *incrutil.Inputs[[]T]) (output T, _ error)

func TableColumn

func TableColumn[Output any](_ context.Context, columnIndex int64, input *types.Table) (output Output, err error)

TableColumn selects the values from a given column by index.

func TimeseriesChart

func TimeseriesChart(config ChartConfig) func(context.Context, []time.Time, []float64) (types.SVG, error)

TimeseriesChart renders a chart to svg.

func TimestampAsc

func TimestampAsc(t0, t1 time.Time) int

func Zero

func Zero[T any]() (output T)

Types

type ChartConfig

type ChartConfig struct {
	Height                  int    `json:"height"`
	Width                   int    `json:"width"`
	CanvasColor             string `json:"canvas_color"`
	BackgroundColor         string `json:"background_color"`
	SeriesFillColor         string `json:"series_fill_color"`
	SeriesStrokeColor       string `json:"series_stroke_color"`
	RegressionStrokeColor   string `json:"regression_stroke_color"`
	RegressionFillColor     string `json:"regression_fill_color"`
	HideAxisLabels          bool   `json:"hide_axis_labels"`
	HideSeries              bool   `json:"hide_series"`
	HideSeriesLastValue     bool   `json:"hide_series_last_value"`
	HideRegression          bool   `json:"hide_regression"`
	HideRegressionLastValue bool   `json:"hide_regression_last_value"`
}

ChartConfig is a set of configurable options for charts.

func ParseChartConfig

func ParseChartConfig(expression string) (output ChartConfig)

ParseChartConfig parses a chart config from an expression.

func (ChartConfig) ApplyChart

func (cc ChartConfig) ApplyChart(target *chart.Chart)

ApplyChart applies the chart config to the chart itself.

func (ChartConfig) ApplyChartThumbnail

func (cc ChartConfig) ApplyChartThumbnail(target *chart.Chart)

ApplyChartThumbnail applies the chart config to the chart itself.

func (ChartConfig) ApplyPrimaryContinuousSeries

func (cc ChartConfig) ApplyPrimaryContinuousSeries(primarySeries *chart.ContinuousSeries)

ApplyPrimaryContinuousSeries applies the chart config to the primary series.

func (ChartConfig) ApplyPrimaryTimeSeries

func (cc ChartConfig) ApplyPrimaryTimeSeries(primarySeries *chart.TimeSeries)

ApplyPrimarySeries applies the chart config to the primary series.

func (ChartConfig) ApplyRegressionSeries

func (cc ChartConfig) ApplyRegressionSeries(regressionSeries *chart.LinearRegressionSeries)

ApplyRegressionSeries applies the chart config to the primary series.

type MathScalars

type MathScalars interface {
	int64 | float64 | time.Duration
}

Jump to

Keyboard shortcuts

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