From cc9013009aa09971e79b29725f8a1a0c3c8cb984 Mon Sep 17 00:00:00 2001 From: Joshua MacDonald Date: Tue, 13 Jul 2021 21:36:31 -0700 Subject: [PATCH] Remove a test-only method (#16) * Remove a test-only method * update circle Go version * simplify circleci * mod update --- .circleci/config.yml | 7 +------ go.mod | 2 +- go.sum | 1 + simple/simple.go | 7 +------ varopt_test.go | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b31eb32..3b06f3c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,13 +4,8 @@ jobs: test: working_directory: ~/go/src/github.com/lightstep/varopt docker: - - image: circleci/golang:1.13 + - image: circleci/golang:1.15 steps: - - run: - name: "configure environment" - command: | - echo 'export GOPATH="$HOME/go"' >> $BASH_ENV - source $BASH_ENV - checkout - run: go test -v ./... diff --git a/go.mod b/go.mod index 1f0ead4..e61e0b6 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/lightstep/varopt -go 1.13 +go 1.15 require github.com/stretchr/testify v1.4.0 diff --git a/go.sum b/go.sum index e863f51..8fdee58 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/simple/simple.go b/simple/simple.go index c086dfa..e3fb340 100644 --- a/simple/simple.go +++ b/simple/simple.go @@ -53,17 +53,12 @@ func (s *Simple) Get(i int) varopt.Sample { return s.buffer[i] } -// Get returns the number of items in the sample. If the reservoir is +// Size returns the number of items in the sample. If the reservoir is // full, Size() equals Capacity(). func (s *Simple) Size() int { return len(s.buffer) } -// Weight returns the adjusted weight of each item in the sample. -func (s *Simple) Weight() float64 { - return float64(s.observed) / float64(s.Size()) -} - // Count returns the number of items that were observed. func (s *Simple) Count() int { return s.observed diff --git a/varopt_test.go b/varopt_test.go index 484cf47..a56c691 100644 --- a/varopt_test.go +++ b/varopt_test.go @@ -113,7 +113,7 @@ func testUnbiased(t *testing.T, bbr, bsr float64) { ss.Add(s) } - weight := ss.Weight() + weight := float64(ss.Count()) / float64(ss.Size()) for i := 0; i < ss.Size(); i++ { vsample.Add(ss.Get(i), weight) }