File: example_dense_compat_test.go

package info (click to toggle)
golang-github-gorgonia-tensor 0.9.24-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,696 kB
  • sloc: sh: 18; asm: 18; makefile: 8
file content (32 lines) | stat: -rw-r--r-- 620 bytes parent folder | download
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]
}