1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package tensor_test
import (
"fmt"
"github.com/apache/arrow-go/v18/arrow/array"
"github.com/apache/arrow-go/v18/arrow/memory"
"gorgonia.org/tensor"
)
func ExampleDense_Arrow() {
pool := memory.NewGoAllocator()
b := array.NewFloat64Builder(pool)
defer b.Release()
b.AppendValues(
[]float64{1, 2, 3, -1, 4, 5},
[]bool{true, true, true, false, true, true},
)
arr := b.NewFloat64Array()
defer arr.Release()
fmt.Printf("arrow array = %v\n", arr)
a := tensor.FromArrowArray(arr)
fmt.Printf("tensor = %v\n", a)
// Output:
// arrow array = [1 2 3 (null) 4 5]
// tensor = C[ 1 2 3 -- 4 5]
}
|