xx

package
v0.0.0-...-5ea3ca1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Full - returns the convolution at each point of overlap, i.e. of length N+M-1.
	Full = iota
	// Same - returns the output of length max(M, N).
	Same
	// Valid - returns the output of length max(M, N) - min(M, N) + 1.
	Valid
)
View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func ARange

func ARange(start int, stop int) []float64

ARange implements `np.ARange` - i.e. returns a list of integers (start, ..., stop - 1) in the form of []float64

func Abs

func Abs(a float64) float64

func AbsDiffInt

func AbsDiffInt(x, y int) int

func AbsInt

func AbsInt(x int) int

func ArgSort

func ArgSort(s []float64) []int

ArgSort min > max

func ArgSortMaxToMin

func ArgSortMaxToMin(s []float64) []int

ArgSortMaxToMin max > min

func Avg

func Avg(s []float64) float64

func BisectLeft

func BisectLeft(s []float64, v float64) int

BisectLeft all(val >= x for val in a) // https://docs.python.org/ 3 /library/bisect.html

func BisectRight

func BisectRight(s []float64, v float64) int

BisectRight all(val > x for val in a) // https://docs.python.org/ 3 /library/bisect.html

func ByteToPng

func ByteToPng(imgByte []byte, path string) error

func CalcPercent

func CalcPercent(i interface{}, total interface{}) int

func Capitalize

func Capitalize(i string) string

func ClearAndF64

func ClearAndF64(i interface{}) float64

func CompareF64

func CompareF64(a, b float64, Operation string) bool

func CompareStruct

func CompareStruct(aa interface{}, oo interface{}, ExceptKeys ...string) (keys []string)

func CompressZLib

func CompressZLib(src []byte) ([]byte, error)

func Convolve

func Convolve(a, v []float64, mode ConvolutionMode) []float64

Convolve is a (very naive) implementation of precise discrete convolution. The results are numerically equivalent to `np.convolve(a, v, mode)` - it looks like that `np.convolve` uses precise convolution as well (but not an FFT approximation). TODO: optimize the implementation - the current one has O((M+N)^2) time complexity. Looks like it's possible to achieve at least O(MN).

func Copy

func Copy(src interface{}, dst interface{}) error

func CopySF64

func CopySF64(src []float64) []float64

func CopySInt

func CopySInt(src []int) []int

func CopyST

func CopyST(s []string) []string

func Cross2Line

func Cross2Line(x1, x2, y1, y2 float64) bool

Cross2Line line1: x1,x2 line2: y1,y2

func CrossPosList

func CrossPosList(s []float64, limit float64) []int

func DecryptUnCompressUnpackTo

func DecryptUnCompressUnpackTo(src []byte, dst interface{}, key string) (err error)

func DecryptUnpack

func DecryptUnpack(src []byte, key string) (dst interface{}, err error)

func Default

func Default(OriginalValue, v string) string

func DefaultF64

func DefaultF64(OriginalValue, v float64) float64

func DefaultInt

func DefaultInt(OriginalValue, v int) int

func DefaultInt64

func DefaultInt64(OriginalValue, v int64) int64

func DefaultST

func DefaultST(OriginalValue, v []string) []string

func DelSStr

func DelSStr(s []string, delValue string) []string

func DeprecatedTest deprecated

func DeprecatedTest(i float64) float64

Deprecated: Use Other

func Diff

func Diff(s []float64) float64

func DiffOneValue

func DiffOneValue(s []float64, v float64) []float64

func DiffTowSliceMax

func DiffTowSliceMax(s1, s2 []float64, validPercent ...float64) float64

func Encrypt

func Encrypt(plainText, key, iv string) (dst []byte, err error)

func EqualSF

func EqualSF(a, b []float64) bool

func EqualSI

func EqualSI(a, b []int) bool

func EqualStr

func EqualStr(a []string, b []string) bool

func F64

func F64(i interface{}) float64

func F64Str

func F64Str(v float64, decimals ...int) string

func F64s

func F64s(s []string) []float64

func F64sAdd

func F64sAdd(i []float64, a float64, decimals ...int) []float64

func F64sGTIdx

func F64sGTIdx(s []float64, limit float64) int

Greater Than

func F64sReverse

func F64sReverse(i []float64, decimals ...int) []float64

func FileExists

func FileExists(f string) bool

func First

func First(s S, defaultValue ...interface{}) interface{}

func FirstBool

func FirstBool(s []bool, defaultValue ...bool) bool

func FirstF64

func FirstF64(s []float64, defaultV ...float64) float64

func FirstInt

func FirstInt(s []int, defaultValue ...int) int

func FirstStr

func FirstStr(s []string, defaultV ...string) string

func Float64sAddRandom

func Float64sAddRandom(i []float64, x1 float64, x2 float64, decimals ...int) []float64

func Float64sSortMaxToMin

func Float64sSortMaxToMin(s []float64) []float64

Float64sSortMaxToMin max > min

func GetFieldDiffOne

func GetFieldDiffOne(a, o interface{}) (keyList []string, v1List []string, v2List []string)

func GetS

func GetS(s []interface{}, p int) interface{}

func GetSF

func GetSF(s []float64, p int) float64

func GetSInt

func GetSInt(s []int, p int) int

func GetST

func GetST(s []string, p int, defaultValue ...string) string

func GetType

func GetType(i interface{}) reflect.Type

func HexToInt64

func HexToInt64(i string) (int64, error)

func IdxS

func IdxS(i interface{}, s S) int

func IdxSI

func IdxSI(i int, s SI) int

func IdxST

func IdxST(i string, s []string) int

func If

func If(cdt bool, a interface{}, b interface{}) interface{}

func IfErr

func IfErr(cdt bool, a interface{}, s ...interface{}) error

func IfErr2

func IfErr2(cdt bool, a, b error) error

func IfF64

func IfF64(cdt bool, a float64, b float64) float64

func IfInt

func IfInt(cdt bool, a int, b int) int

func IfInt64

func IfInt64(cdt bool, a int64, b int64) int64

func IfPanic

func IfPanic(cdt bool, s ...interface{})

If evaluates a condition, if true returns the first parameter otherwise the second

func IfSF

func IfSF(cdt bool, a []float64, b []float64) []float64

func IfSI

func IfSI(cdt bool, a []int, b []int) []int

func IfSST

func IfSST(cdt bool, a [][]string, b [][]string) [][]string

func IfST

func IfST(cdt bool, a []string, b []string) []string

func IfStr

func IfStr(cdt bool, a string, b string) string

func InF64

func InF64(i, x1, x2 float64) float64

InF64 value in Min Max

func InInt

func InInt(i, x1, x2 int) int

InInt value in Min Max

func InRangeF64

func InRangeF64(i, minVal, maxVal float64) float64

func InRangeInt

func InRangeInt(i, minVal, maxVal int) int

func InRangeInt64

func InRangeInt64(i, minVal, maxVal int64) int64

func InSF

func InSF(i float64, s []float64) bool

func InSI

func InSI(i int, s []int) bool

func InSSF

func InSSF(i []float64, ss [][]float64) bool

func InSSI

func InSSI(si []int, ssi [][]int) bool

func InST

func InST(i string, s []string) bool

func InSTIgnore

func InSTIgnore(i string, s ...string) bool

func InSlice

func InSlice(i string, s []string) bool

func InStringList

func InStringList(i string, s []string) bool

func InsertSF64

func InsertSF64(s []float64, index int, value float64) []float64

func InsertSStr

func InsertSStr(s []string, index int, value string) []string

func Int

func Int(i interface{}) int

func Int64

func Int64(i interface{}) int64

func IntDiffOneValue

func IntDiffOneValue(s []int, v int) []int

func IntListReverse

func IntListReverse(i []int) []int

func IntSAdd

func IntSAdd(i []int, a int) []int

func IntZ2

func IntZ2(i int) string

IntZ2 ZFill

func IntZ3

func IntZ3(i int) string

IntZ3 ZFill

func IntZ8

func IntZ8(i int) string

IntZ8 ZFill

func Intersect

func Intersect(a, b []string) []string

func IntersectSize

func IntersectSize(a, b []string) int

func IsEmptyStr

func IsEmptyStr(i string) bool

IsEmptyStr gregex.IsMatchString(`^\s*$`, i)

func IsErr

func IsErr(e1 error, e2 error) bool

func IsInRangeF64

func IsInRangeF64(i, minVal, maxVal float64) bool

func IsPointer

func IsPointer(value interface{}) error

func IsUuid

func IsUuid(i string) bool

func Join

func Join(s ...interface{}) string

func JoinRmEmpty

func JoinRmEmpty(sep string, s ...interface{}) string

func LastF64

func LastF64(s []float64, defaultV ...float64) float64

func LastStr

func LastStr(s []string, defaultV ...string) string

func LinSpace

func LinSpace(start, end float64, num int) []float64

LinSpace implements `np.LinSpace` - i.e. splits the interval [start, end] into `num - 1` equal intervals and returns `num` split points.

func LineToLog

func LineToLog(i float64) float64

10 * math.Log10(i)

func LineToLogs

func LineToLogs(i []float64) []float64

func Linspace

func Linspace(start, end float64, num int) []float64

func LogToLine

func LogToLine(i float64) float64

math.Pow(10, i/10.0)

func LogToLineSumLineToLog

func LogToLineSumLineToLog(i []float64) float64

func LogToLines

func LogToLines(i []float64) []float64

func LstSq

func LstSq(a, b *mat.Dense) *mat.Dense

LstSq computes least-squares solution to equation A*x = b, i.e. computes a vector x such that the 2-norm “|b - A x|“ is minimized. Based on: https://github.com/scipy/scipy/blob/v1.3.0rc1/scipy/linalg/basic.py#L1042

func MakeFloat64

func MakeFloat64(length int, v float64) []float64

func MapKeyInts

func MapKeyInts(m map[int]interface{}) []int

func MapKeys

func MapKeys(m map[string]interface{}) []string

func MapKvReverse

func MapKvReverse(kv g.MapStrStr) g.MapStrStr

func MapValueF64s

func MapValueF64s(m map[string]float64) []float64

func Max

func Max(s []float64) float64

func MaxF64

func MaxF64(s ...float64) float64

func MaxIdx

func MaxIdx(s []float64) int

func MaxInt

func MaxInt(s []int) int

func MaxInt64

func MaxInt64(s ...int64) int64

func MaxIntIdx

func MaxIntIdx(s []int) int

func MergeMapStrStr

func MergeMapStrStr(maps ...map[string]string) map[string]string

func MergeStr

func MergeStr(a, b []string) []string

func Min

func Min(s []float64) float64

func MinF64

func MinF64(s ...float64) float64

func MinIdx

func MinIdx(s []float64) int

func MinInt

func MinInt(s []int) int

func MinIntIdx

func MinIntIdx(s []int) int

func MinMaxInt

func MinMaxInt(s []int) (int, int, int, int)

MinMaxInt return min,minIdx,max,maxIdx

func MsToStr

func MsToStr(i int64, format string) string

MsToStr format default Y-m-d

func MustIn

func MustIn(i string, s ...string) error

func MustInF64

func MustInF64(i float64, s ...float64) error

func MustInInt

func MustInInt(i int, s ...int) error

func Ones

func Ones(size int) []float64

Ones return an array of ones of specified size.

func OrFloat

func OrFloat(a float64, b ...float64) float64

func OrInt

func OrInt(a int, b ...int) int

func OrString

func OrString(a string, b ...string) string

func Pack

func Pack(src interface{}) ([]byte, error)

func PackCompress

func PackCompress(src interface{}) ([]byte, error)

func PackCompressEncrypt

func PackCompressEncrypt(src interface{}, key string) (dst []byte, err error)

PackEncrypt Note that the key must be 16/24/32 bit length.

func PartSF

func PartSF(s []float64, maxLength int) []float64

func PartSI

func PartSI(s []int, maxLength int) []int

func PermutationsInt

func PermutationsInt(s []int) [][]int

func PrintMemUsage

func PrintMemUsage()

func ProductSF64

func ProductSF64(ssf [][]float64) [][]float64

func PullUp01

func PullUp01(src [][]float64, point int) [][]float64

PullUp01 拉点

func R0

func R0(i float64) float64

R0 Round 1

func R0s

func R0s(s []float64) []float64

Copy

func R1

func R1(i float64) float64

Round 1

func R1s

func R1s(s []float64) []float64

func R2

func R2(i float64) float64

Round 2

func R2s

func R2s(s []float64) []float64

Copy

func R3

func R3(i float64) float64

Round 3

func R3s

func R3s(s []float64) []float64

func R4

func R4(i float64) float64

R4 Round 4

func R5

func R5(i float64) float64

R5 Round 5

func R6

func R6(i float64) float64

R6 Round 6

func R6s

func R6s(s []float64) []float64

func R8

func R8(i float64) float64

R8 Round 8

func R9

func R9(i float64) float64

R9 Round 9

func RandomF64

func RandomF64(x1, x2 float64, decimals ...int) float64

RandomF64 decimals default 6

func RandomF64s

func RandomF64s(x1, x2 float64, n int, decimals ...int) []float64

func RandomInSF64

func RandomInSF64(s ...float64) float64

func RandomInt

func RandomInt(x1, x2 int) int

RandomInt [min to max] (include min max)

func RandomIntInSI

func RandomIntInSI(s []int) int

func RandomIntS

func RandomIntS(x1, x2 int, n int) []int

func RandomLetter

func RandomLetter(length int) string

func RandomLetterLower

func RandomLetterLower(length int) string

func RandomNumber

func RandomNumber(length int) string

func RandomSliceIntUnique

func RandomSliceIntUnique(x1, x2, count int) []int

func RandomStrInST

func RandomStrInST(s []string) string

func Range

func Range(start, stop int) []float64

Range 0,3 > [0,1,2]

func RangeInt

func RangeInt(start, stop int) []int

RangeInt 0,3 > [0,1,2]

func RemoveDuplicateFloat64

func RemoveDuplicateFloat64(s []float64) []float64

func RemoveDuplicateInt

func RemoveDuplicateInt(s []int) []int

func RemoveDuplicateStr

func RemoveDuplicateStr(s []string) []string

func RemoveItemInST

func RemoveItemInST(s []string, removeItem string) []string

func ReplaceAndInt

func ReplaceAndInt(i interface{}) int

func ReverseF64

func ReverseF64(s []float64) []float64

func ReverseST

func ReverseST(s []string) []string

func Round

func Round(i float64, decimals ...int) float64

Round decimals: 6

func Rounds

func Rounds(s []float64, decimals ...int) []float64

Rounds Copy

func SF64Index

func SF64Index(i float64, s []float64) int

func SStrIndex

func SStrIndex(i string, s []string) int

func SafeFilename

func SafeFilename(i string) string

func SameMapStrStr

func SameMapStrStr(a map[string]string, b map[string]string) bool

func Sha1

func Sha1(v interface{}) string

func Sha3

func Sha3(v interface{}) string

func Sha3Bytes

func Sha3Bytes(v []byte) string

func Sha3File

func Sha3File(path string) string

func Show

func Show(i interface{})

func ShowBytes

func ShowBytes(i []byte)

func ShowDetail

func ShowDetail(i interface{})

func ShowType

func ShowType(i interface{})

func Sleep

func Sleep(s float64, show ...int)

Sleep Second

func SliceEqual

func SliceEqual(a S, b S) bool

func SliceEqualST

func SliceEqualST(a []string, b []string) bool

func SliceFloat64Equal

func SliceFloat64Equal(a []float64, b []float64) bool

func SliceStrRepeat

func SliceStrRepeat(i string, num int) []string

func SortMapByKey

func SortMapByKey(m map[string]interface{}) []string

func SortMapByValue

func SortMapByValue(m map[string]float64) []string

func SortMapByValueInt

func SortMapByValueInt(m map[string]int) []string

max to min

func SortMapByValueIntMinToMax

func SortMapByValueIntMinToMax(m map[string]int) []string

func Split01

func Split01(src []float64) [][]float64

Split01 一维变二维

func Str

func Str(i interface{}) string

func StrToMs

func StrToMs(i string, format string) int64

StrToMs format default Y-m-d

func SubStr

func SubStr(str string, start int, length ...int) string

func SubStringHan

func SubStringHan(s string, n int) string

返回一个字符串的前 n 个字符,其中中文字符的长度为 2:

func Sum

func Sum(s []float64) float64

Sum Sum

func SumWhereGT

func SumWhereGT(src [][]float64, limit, a, b float64) []float64

SumWhereGT 2维变1维,然后相加

func T1

func T1(title ...interface{})

func T2

func T2(title ...interface{})

func TestAssert12

func TestAssert12(t *gtest.T, e1, e2 error, v0, v1, v2 interface{})

func ToMaxF64

func ToMaxF64(y []float64, maxVal float64) []float64

func ToMinF64

func ToMinF64(y []float64, minVal float64) []float64

func ToMs

func ToMs(i float64) float64

func ToPercent

func ToPercent(i float64) float64

func TodayDate

func TodayDate() string

TodayDate ... Y-m-d

func TryExpect

func TryExpect()

func UnCompressUnpack

func UnCompressUnpack(src []byte) (dst interface{}, err error)

func UnCompressUnpackTo

func UnCompressUnpackTo(src []byte, dst interface{}) (err error)

func UnCompressZLib

func UnCompressZLib(src []byte) ([]byte, error)

func Unpack

func Unpack(src []byte) (dst interface{}, err error)

func UnpackTo

func UnpackTo(src []byte, dst interface{}) (err error)

func WhereGE

func WhereGE(s []float64, limit, a, b float64) []float64

func WhereGT

func WhereGT(s []float64, limit, a, b float64) []float64

func WhereGT2

func WhereGT2(s []float64, limit float64) []float64

func WhereGtNum

func WhereGtNum(s []float64, limit float64) (num int)

func WhereGtSI

func WhereGtSI(s []int, limit, a, b int) []int

func WhereLT

func WhereLT(s []float64, limit, a, b float64) []float64

func WhereLtNum

func WhereLtNum(s []float64, limit float64) (num int)

func YListLogToLineAndP2PLineToLog

func YListLogToLineAndP2PLineToLog(yList [][]float64) []float64

func YListP2PSum

func YListP2PSum(yList [][]float64) []float64

func Z1

func Z1(i float64) string

Z1 ZFill

func Z2

func Z2(i float64) string

Z2 ZFill

func Z3

func Z3(i float64) string

Z3 ZFill

func Z4

func Z4(i float64) string

Z4 ZFill

func ZFill

func ZFill(i float64, decimals int) string

func Zeroes

func Zeroes(size int) []float64

Zeroes returns an array of zeroes of specified size. It's encouraged to use it instead of just make() in case the further code relies on the fact that the array contains zeroes.

func Zzz

func Zzz(title ...string)

Types

type ConvolutionMode

type ConvolutionMode int

ConvolutionMode defines convolution output array length.

type Ip2LocationRecord

type Ip2LocationRecord struct {
	CountryShort string
	Country      string
	Province     string // Region Province
	City         string
}

func Ip2Location

func Ip2Location(ipList []string) ([]*Ip2LocationRecord, error)

Ip2Location ... Country / CountryShort / Province / City

type PsInfo

type PsInfo struct {
	Memory PsInfoItem
	Disk   PsInfoItem
	Load   PsInfoLoad
	Uptime uint64
}

func GetPsInfo

func GetPsInfo() (a PsInfo)

GetPsInfo ...

type PsInfoItem

type PsInfoItem struct {
	Total       float64
	Used        float64
	Free        float64
	UsedPercent float64
}

type PsInfoLoad

type PsInfoLoad struct {
	Avg1  float64
	Avg5  float64
	Avg15 float64
}

type S

type S = []interface{}

func IfS

func IfS(cdt bool, a S, b S) S

func Reverse

func Reverse(s S) S

type SF

type SF = []float64

type SI

type SI = []int

type SS

type SS = [][]interface{}

type SSF

type SSF = [][]float64

type SSI

type SSI = [][]int

type SST

type SST = [][]string

type SStr

type SStr = []string

type ST

type ST = []string

Jump to

Keyboard shortcuts

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