misc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareFloats

func CompareFloats(x float64, y float64) (max float64, min float64)

CompareFloats returns maximum and minimum of two floats taking NaNs into account

func CompareSliceInts

func CompareSliceInts(newslice []int, master []int) (idx []int)

CompareSliceInts CompareSliceInts

func DeltaF

func DeltaF(floats []float64) []float64

DeltaF returns delta between consecutive floats in a slice

func DeltaI

func DeltaI(ints []int) []int

DeltaI returns delta between consecutive ints in a slice

func Dropna

func Dropna(slice []float64) []float64

Dropna drop NaNs from a slice

func EnsureFolder

func EnsureFolder(root string) string

EnsureFolder EnsureFolder

func ExtractSources

func ExtractSources(input string) [3]int

ExtractSources returns the levels a,b,c as integer list

func FileExists

func FileExists(filename string) bool

FileExists FileExists

func Fillna

func Fillna(slice []float64, method string, prefill bool, validTime int) []float64

Fillna Fills NaN values with a value base on method. method "previous" fills with previous value,method "linear" fills the NaNs with linear interpolation If no previous value found for filling, first valid value can be used by setting prefill=true validTime (higher number than 1) sets the sample's lifetime. If the sample "dies", NaN is written. This overrides prefill = true -setting

func Find

func Find(slice []string, val string) (int, bool)

Find Find

func FindFloatIndex

func FindFloatIndex(slice []float64, val float64) int

FindFloatIndex finds the index of first occurrence of the given value

func FindInt

func FindInt(slice []int, val int) (int, bool)

FindInt FindInt

func FindStringposition

func FindStringposition(slice []string, s string) int

FindStringposition returns the first occurrence index of given string. Returns -1 if string was not found.

func FirstOfMonth

func FirstOfMonth(t time.Time) time.Time

FirstOfMonth returns a TZ timestamp of first day of given month

func GetEnvOrDefault

func GetEnvOrDefault(key string, defaultValue string) string

GetEnvOrDefault

func GetSysmemory

func GetSysmemory() float64

func InsertIntoSlice

func InsertIntoSlice(slice []float64, idx int, val float64) []float64

InsertIntoSlice InsertIntoSlice

func IsValidFloat

func IsValidFloat(value float64) bool

IsValidFloat checks whether the given float is a valid number instead of NaN or Inf

func MatchAll

func MatchAll(a string, url string) (paramsMap map[string]string)

MatchAll MatchAll example: Avant(?P<DeviceID>\d{1,})(_S(?P<SlaveID>\d{1,})_C(?P<CellID>\d{1,}))?

func MaxI

func MaxI(a int, b int) int

MaxI returns bigger int from two ints

func MinI

func MinI(a int, b int) int

MinI returns smaller int from two ints

func NanSlice

func NanSlice(size int) (nanslice []float64)

NaNSlice Create a slice of NaNs of given size

func NanosecondsToTime

func NanosecondsToTime(tm int64) time.Time

NanosecondsToTime NanosecondsToTime

func Numberrange

func Numberrange(start int, end int, step int) (numberrange []float64)

Numberrange creates a slice with numbers from start to end, with given step (integer)

func ParseTime

func ParseTime(t string) time.Time

ParseTime ParseTime

func PrettyByte

func PrettyByte(bytes []byte) string

PrettyByte PrettyByte

func RandRange

func RandRange(min int, max int) int

func ReplaceNan

func ReplaceNan(value float64, replacewith float64) float64

ReplaceNan Replaces NaN and Inf with given value

func ReplaceNanSlice

func ReplaceNanSlice(values []float64, replacewith float64) []float64

ReplaceNanSlice Replace NaNs in a slice with given value

func RoundTo

func RoundTo(val float64, digits int) float64

RoundTo rounds the number to given digits

func SetDefaultF

func SetDefaultF(defaultval float64, confval float64) float64

SetDefaultF set default value for a parameter, if the configuration value is zero (=initialized empty variable)

func SetDefaultI

func SetDefaultI(defaultval int, confval int) int

SetDefaultI set default value for a parameter, if the configuration value is zero (=initialized empty variable)

func SliceContains

func SliceContains(slice []string, s string) bool

SliceContains sliceContains

func SliceNumberContains

func SliceNumberContains(slice []int, s int) bool

SliceNumberContains SliceNumberContains

func StringInSlice

func StringInSlice(slice []string, s string, ignorecase bool) bool

func StringToFloat64

func StringToFloat64(s string) float64

func StringToInt

func StringToInt(s string) int

StringToInt StringToInt

func StringToTime

func StringToTime(t string) time.Time

StringToTime StringToTime

func TimeToMicroseconds

func TimeToMicroseconds(tm time.Time) int64

TimeToMicroseconds TimeToMicroseconds

func TimeToString

func TimeToString(t time.Time) string

TimeToString TimeToString

func UniqueInts

func UniqueInts(t []int) []int

UniqueInts returns unique ints from given slice of ints

func UniqueStrings

func UniqueStrings(t []string) []string

UniqueStrings returns unique strings from given slice of strings

func Use

func Use(v interface{}) string

Use Use

func Xnor

func Xnor(a, b bool) bool

Types

type Rounded

type Rounded struct {
	Rawvalue float64 // raw value with given digits
	Prefix   string  // prefix string
	Value    float64 // rounded value with given digits and prefix
	Response string  // response as <Value> <Prefix><unit>
}

func RoundPrefix

func RoundPrefix(v float64, digits int, unit string, prefix string) Rounded

RoundPrefix returns the rounded value to given digits and correct prefix (Megas, Kilos etc.) Special case is abs value between 1000....10000 which is not converted to kilos (because I like it like that) set prefix to force certain prefix, otherwise the function figures it out on its' own.

type TimeMeasure

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

TimeMeasure GoPython

func NewTimeMeasure

func NewTimeMeasure() *TimeMeasure

NewTimeMeasure NewTimeMeasure

func (*TimeMeasure) GetMilliseconds

func (t *TimeMeasure) GetMilliseconds() int64

GetMilliseconds GetMilliseconds

func (*TimeMeasure) Print

func (t *TimeMeasure) Print(msg string)

Print print

Jump to

Keyboard shortcuts

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