utils

package
v0.0.0-...-4dcd76e Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ExpFromZeroFunctionName = "expFromZero"
View Source
const LinearFunctionName = "linear"

Variables

This section is empty.

Functions

func CheckValueRange

func CheckValueRange(t *testing.T, valueRange ValueRange, expMin, expMax float64)

func ContainsAll

func ContainsAll(slice *[]Identifiable, values *[]string) bool

func ContainsByIdentity

func ContainsByIdentity(slice *[]Identifiable, value *string) bool

func ContainsInts

func ContainsInts(slice *[]int, value *int) bool

func ContainsString

func ContainsString(slice *[]string, value *string) bool

func DecodeToStruct

func DecodeToStruct(src, target interface{})

func Differs

func Differs(a, b interface{}) bool

func ErrorDiffers

func ErrorDiffers(err interface{}, message string) bool

func ExpectError

func ExpectError(t *testing.T, expectedMessage string) func()

func FloatsAreEqual

func FloatsAreEqual(expected float64, actual float64, epsilon float64) bool

func IsInBounds

func IsInBounds(value float64, lower float64, upper float64) bool

func IsPositive

func IsPositive(value float64) bool

func IsProbability

func IsProbability(value float64) bool

func RandomGenerator

func RandomGenerator(seed int64) *rand.Rand

func RemoveSingleStringOccurrence

func RemoveSingleStringOccurrence(s []string, r string) []string

func ToIdentifiable

func ToIdentifiable(objects IdentifiableIterable) *[]Identifiable

Types

type Array

type Array = []interface{}

type ExpFromZeroFunction

type ExpFromZeroFunction struct {
	Alpha      float64 `json:"alpha"`
	Multiplier float64 `json:"multiplier"`
}

func (*ExpFromZeroFunction) Evaluate

func (e *ExpFromZeroFunction) Evaluate(value float64) float64

func (*ExpFromZeroFunction) String

func (e *ExpFromZeroFunction) String() string

type Identifiable

type Identifiable interface {
	Identifier() string
}

type IdentifiableIterable

type IdentifiableIterable interface {
	Get(index int) Identifiable
	Len() int
}

type IdentityMap

type IdentityMap = map[string]Identifiable

func AsMap

func AsMap(objects IdentifiableIterable) *IdentityMap

type LinearFunctionParameters

type LinearFunctionParameters struct {
	A float64 `json:"a"`
	B float64 `json:"b"`
}

func (*LinearFunctionParameters) Evaluate

func (f *LinearFunctionParameters) Evaluate(value float64) (result float64, ok bool)

func (*LinearFunctionParameters) String

func (f *LinearFunctionParameters) String() string

type Map

type Map = map[string]interface{}

type SeededValueGenerator

type SeededValueGenerator = func(seed int64) ValueGenerator

type ToIdentityConverter

type ToIdentityConverter func(interface{}) Identifiable

type ValueGenerator

type ValueGenerator = func() float64

func NewValueInRangeGenerator

func NewValueInRangeGenerator(generator ValueGenerator, valueRange *ValueRange) ValueGenerator

func RandomBasedSeedValueGenerator

func RandomBasedSeedValueGenerator(seed int64) ValueGenerator

type ValueRange

type ValueRange struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

func NewValueRange

func NewValueRange() *ValueRange

func (*ValueRange) Diff

func (r *ValueRange) Diff() float64

func (*ValueRange) ScaleEqually

func (r *ValueRange) ScaleEqually(scale float64) *ValueRange

func (*ValueRange) String

func (r *ValueRange) String() string

Jump to

Keyboard shortcuts

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