Skip to content

Instantly share code, notes, and snippets.

@sdressler
Created December 12, 2022 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdressler/fa1f2b375d68f9c83625bd2024c26f7b to your computer and use it in GitHub Desktop.
Save sdressler/fa1f2b375d68f9c83625bd2024c26f7b to your computer and use it in GitHub Desktop.
Test file for indent-blankline slowness issue
package histogram
import (
"testing"
"pgregory.net/rand"
)
const numBins = 5
/*
func TestMakeQuantileBinEdges(t *testing.T) {
encData := []int{3, 2, 7, 3, 1, 3, 3, 4, 8, 5, 6, 7}
// Unsorted throws an error
_, err := makeEquidistantBins(encData, numBins)
assert.ErrorIs(t, err, consts.ErrLogic)
sort.Ints(encData)
bins, err := makeEquidistantBins(encData, numBins)
require.NoError(t, err)
for idx, bin := range bins {
fmt.Printf("%d: %#v\n", idx, bin)
}
// 1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 7, 8
// assert.Equal(t, []Edge{{1, 3}, {3, 4}, {4, 7}, {7, 8}, {8, 9}}, edges)
}
func TestMakeQuantileBinEdgesNulls(t *testing.T) {
encData := []int{3, -1, 2, 0, 7, -1, 3, 1, 3, 3, -1, 4, 8, 5, 6, 7, -1}
sort.Ints(encData)
edges, err := makeEquidistantBinEdges(encData, tolerance)
require.NoError(t, err)
// -1, -1, -1, -1, 0, 1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 7, 8
assert.Equal(t, []Edge{{-1, 0}, {0, 3}, {3, 4}, {4, 7}, {7, 8}, {8, 9}}, edges)
}
// Special test to ensure NULLs always get their own bin
func TestMakeQuantileBinEdgesNulls2(t *testing.T) {
encData := []int{3, -1, 2, 0, 7, 3, 1, 3, 3, 4, 8, 5, 6, 7}
sort.Ints(encData)
edges, err := makeEquidistantBinEdges(encData, tolerance)
require.NoError(t, err)
// -1, 0, 1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 7, 8
assert.Equal(t, []Edge{{-1, 0}, {0, 3}, {3, 4}, {4, 7}, {7, 8}, {8, 9}}, edges)
}
func TestMakeDistinctBinEdges(t *testing.T) {
edges, err := makeDistinctBinEdges(5, false)
require.NoError(t, err)
assert.Len(t, edges, 5)
assert.Equal(t, []Edge{{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 5}}, edges)
}
func TestMakeDistinctBinEdgesNulls(t *testing.T) {
edges, err := makeDistinctBinEdges(5, true)
require.NoError(t, err)
assert.Len(t, edges, 5)
assert.Equal(t, []Edge{{-1, 0}, {0, 1}, {1, 2}, {2, 3}, {3, 4}}, edges)
}
*/
func TestQuantiles(t *testing.T) {
rng := rand.New(0)
data := make([]int, 1000)
for idx := range data {
data[idx] = rng.Intn(100)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment