testutils

package
v0.0.0-...-9165f38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CartesianProduct

func CartesianProduct(create func(numOut int), set func(out, dim, dimPos int), dims ...int)
Example
intCartesianProduct := func(data [][]int) [][]int {
	var out [][]int
	create := func(n int) {
		out = make([][]int, n)
	}
	set := func(outIdx, dim, dimPos int) {
		if out[outIdx] == nil {
			out[outIdx] = make([]int, len(data))
		}
		out[outIdx][dim] = data[dim][dimPos]
	}
	lengths := make([]int, 0, len(data))
	for _, d := range data {
		lengths = append(lengths, len(d))
	}
	CartesianProduct(create, set, lengths...)
	return out
}
inputs := [][]int{
	{1, 2, 3},
	{11, 22},
	{111},
	{1111, 2222},
}
fmt.Println("inputs:")
for _, p := range inputs {
	fmt.Println(p)
}
fmt.Println()
outputs := intCartesianProduct(inputs)
fmt.Println("outputs:")
for _, p := range outputs {
	fmt.Println(p)
}
Output:

inputs:
[1 2 3]
[11 22]
[111]
[1111 2222]

outputs:
[1 11 111 1111]
[1 11 111 2222]
[1 22 111 1111]
[1 22 111 2222]
[2 11 111 1111]
[2 11 111 2222]
[2 22 111 1111]
[2 22 111 2222]
[3 11 111 1111]
[3 11 111 2222]
[3 22 111 1111]
[3 22 111 2222]

func CombineOptions

func CombineOptions(options ...[]tdigest.Option) [][]tdigest.Option

Types

type Options

type Options []tdigest.Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL