代码拉取完成,页面将自动刷新
package num
import (
"bytes"
"fmt"
"gitee.com/quant1x/num/internal/functions"
"reflect"
"runtime"
)
// SetAvx2Enabled 设定AVX2加速开关, 非线程安全
func SetAvx2Enabled(enabled bool) {
functions.SetAcceleration(enabled)
}
// GetAvx2Enabled 获取avx2加速状态
func GetAvx2Enabled() bool {
return functions.UseAVX2
}
var (
IgnoreParseExceptions = true // 忽略解析异常
)
// ExtractValueFromPointer 从指针/地址提取值
// Extract value from pointer
func ExtractValueFromPointer(v any) (any, bool) {
vv := reflect.ValueOf(v)
if vv.Kind() == reflect.Pointer {
if vv.IsNil() {
return nil, true
}
ve := vv.Elem()
return ve.Interface(), true
}
return v, false
}
// Array 获取any类型切片数据
type Array interface {
Values() any // 保持原类型
}
// DTypeArray 获取DType切片的接口
type DTypeArray interface {
DTypes() []DType // to dtype
}
// PanicTrace panic 堆栈信息
func PanicTrace(err interface{}) string {
buf := new(bytes.Buffer)
_, _ = fmt.Fprintf(buf, "%v\n", err)
for i := 1; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
break
}
_, _ = fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc)
}
return buf.String()
}
// StringFormatter is used to convert a value
// into a string. Val can be nil or the concrete
// type stored by the series.
type StringFormatter func(val any) string
// DefaultFormatter will return a string representation
// of the data in a particular row.
func DefaultFormatter(v any) string {
if v == nil {
return StringNaN
}
return fmt.Sprintf("%v", v)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。