github.com/wzzhu/tensor@v0.9.24/example_dense_compat_test.go (about)

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