MCPcopy
hub / github.com/montanaflynn/stats / LoadRawData

Function LoadRawData

load.go:12–199  ·  view source on GitHub ↗

LoadRawData parses and converts a slice of mixed data types to floats

(raw interface{})

Source from the content-addressed store, hash-verified

10
11// LoadRawData parses and converts a slice of mixed data types to floats
12func LoadRawData(raw interface{}) (f Float64Data) {
13 var r []interface{}
14 var s Float64Data
15
16 switch t := raw.(type) {
17 case []interface{}:
18 r = t
19 case []uint:
20 for _, v := range t {
21 s = append(s, float64(v))
22 }
23 return s
24 case []uint8:
25 for _, v := range t {
26 s = append(s, float64(v))
27 }
28 return s
29 case []uint16:
30 for _, v := range t {
31 s = append(s, float64(v))
32 }
33 return s
34 case []uint32:
35 for _, v := range t {
36 s = append(s, float64(v))
37 }
38 return s
39 case []uint64:
40 for _, v := range t {
41 s = append(s, float64(v))
42 }
43 return s
44 case []bool:
45 for _, v := range t {
46 if v {
47 s = append(s, 1.0)
48 } else {
49 s = append(s, 0.0)
50 }
51 }
52 return s
53 case []float64:
54 return Float64Data(t)
55 case []int:
56 for _, v := range t {
57 s = append(s, float64(v))
58 }
59 return s
60 case []int8:
61 for _, v := range t {
62 s = append(s, float64(v))
63 }
64 return s
65 case []int16:
66 for _, v := range t {
67 s = append(s, float64(v))
68 }
69 return s

Callers 7

ExampleLoadRawDataFunction · 0.92
TestLoadRawDataFunction · 0.92
ExampleMinFunction · 0.92
TestSigmoidMethodFunction · 0.92
TestSoftMaxMethodFunction · 0.92
TestEntropyMethodFunction · 0.92
mainFunction · 0.92

Calls 1

Float64DataTypeAlias · 0.85

Tested by 6

ExampleLoadRawDataFunction · 0.74
TestLoadRawDataFunction · 0.74
ExampleMinFunction · 0.74
TestSigmoidMethodFunction · 0.74
TestSoftMaxMethodFunction · 0.74
TestEntropyMethodFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…