spatial/r1: import and rename from bound
* spatial/r1: import and rename from bound
Mechanically generated with:
$> gomvpkg -from gonum.org/v1/gonum/bound -to gonum.org/v1/gonum/spatial/r1 -vcs_mv_cmd "git mv {{.Src}} {{.Dst}}"
Fixes
RENAME
bound/doc.go
spatial/r1/doc.go
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package bound provides types for bounded data.
-package bound // import "gonum.org/v1/gonum/bound"
+// Package r1 provides 1D vectors and intervals and operations on them.
+package r1 // import "gonum.org/v1/gonum/spatial/r1"

RENAME
bound/bound.go
spatial/r1/interval.go
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package bound
+package r1
-// Bound represents [Min, Max] bounds.
-type Bound struct {
+// Interval represents an interval.
+type Interval struct {
Min, Max float64
}

MODIFY
stat/distmv/statdist.go
stat/distmv/statdist.go
@@ -7,10 +7,10 @@ package distmv
import (
"math"
- "gonum.org/v1/gonum/bound"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/mathext"
+ "gonum.org/v1/gonum/spatial/r1"
"gonum.org/v1/gonum/stat"
)
@@ -76,7 +76,7 @@ func (Bhattacharyya) DistUniform(l, r *Uniform) float64 {
// unifLogVolOverlap computes the log of the volume of the hyper-rectangle where
// both uniform distributions have positive probability.
-func unifLogVolOverlap(b1, b2 []bound.Bound) float64 {
+func unifLogVolOverlap(b1, b2 []r1.Interval) float64 {
var logVolOverlap float64
for dim, v1 := range b1 {
v2 := b2[dim]

MODIFY
stat/distmv/statdist_test.go
stat/distmv/statdist_test.go
@@ -10,9 +10,9 @@ import (
"golang.org/x/exp/rand"
- "gonum.org/v1/gonum/bound"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
+ "gonum.org/v1/gonum/spatial/r1"
)
func TestBhattacharyyaNormal(t *testing.T) {
@@ -62,14 +62,14 @@ func TestBhattacharyyaUniform(t *testing.T) {
tol float64
}{
{
- a: NewUniform([]bound.Bound{{-3, 2}, {-5, 8}}, rnd),
- b: NewUniform([]bound.Bound{{-4, 1}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{-3, 2}, {-5, 8}}, rnd),
+ b: NewUniform([]r1.Interval{{-4, 1}, {-7, 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
{
- a: NewUniform([]bound.Bound{{-3, 2}, {-5, 8}}, rnd),
- b: NewUniform([]bound.Bound{{-5, -4}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{-3, 2}, {-5, 8}}, rnd),
+ b: NewUniform([]r1.Interval{{-5, -4}, {-7, 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
@@ -257,14 +257,14 @@ func TestKullbackLeiblerUniform(t *testing.T) {
tol float64
}{
{
- a: NewUniform([]bound.Bound{{-5, 2}, {-7, 12}}, rnd),
- b: NewUniform([]bound.Bound{{-4, 1}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{-5, 2}, {-7, 12}}, rnd),
+ b: NewUniform([]r1.Interval{{-4, 1}, {-7, 10}}, rnd),
samples: 100000,
tol: 1e-2,
},
{
- a: NewUniform([]bound.Bound{{-5, 2}, {-7, 12}}, rnd),
- b: NewUniform([]bound.Bound{{-9, -6}, {-7, 10}}, rnd),
+ a: NewUniform([]r1.Interval{{-5, 2}, {-7, 12}}, rnd),
+ b: NewUniform([]r1.Interval{{-9, -6}, {-7, 10}}, rnd),
samples: 100000,
tol: 1e-2,
},

MODIFY
stat/distmv/uniform.go
stat/distmv/uniform.go
@@ -8,18 +8,18 @@ import (
"math"
"golang.org/x/exp/rand"
- "gonum.org/v1/gonum/bound"
+ "gonum.org/v1/gonum/spatial/r1"
)
// Uniform represents a multivariate uniform distribution.
type Uniform struct {
- bounds []bound.Bound
+ bounds []r1.Interval
dim int
rnd *rand.Rand
}
// NewUniform creates a new uniform distribution with the given bounds.
-func NewUniform(bnds []bound.Bound, src rand.Source) *Uniform {
+func NewUniform(bnds []r1.Interval, src rand.Source) *Uniform {
dim := len(bnds)
if dim == 0 {
panic(badZeroDimension)
@@ -30,7 +30,7 @@ func NewUniform(bnds []bound.Bound, src rand.Source) *Uniform {
}
}
u := &Uniform{
- bounds: make([]bound.Bound, dim),
+ bounds: make([]r1.Interval, dim),
dim: dim,
}
if src != nil {
@@ -50,7 +50,7 @@ func NewUnitUniform(dim int, src rand.Source) *Uniform {
if dim <= 0 {
panic(nonPosDimension)
}
- bounds := make([]bound.Bound, dim)
+ bounds := make([]r1.Interval, dim)
for i := range bounds {
bounds[i].Min = 0
bounds[i].Max = 1
@@ -69,9 +69,9 @@ func NewUnitUniform(dim int, src rand.Source) *Uniform {
// is nil, a new slice is allocated and returned. If the input is non-nil, then
// the bounds are stored in-place into the input argument, and Bounds will panic
// if len(bounds) != u.Dim().
-func (u *Uniform) Bounds(bounds []bound.Bound) []bound.Bound {
+func (u *Uniform) Bounds(bounds []r1.Interval) []r1.Interval {
if bounds == nil {
- bounds = make([]bound.Bound, u.Dim())
+ bounds = make([]r1.Interval, u.Dim())
}
if len(bounds) != u.Dim() {
panic(badInputLength)

MODIFY
stat/distmv/uniform_test.go
stat/distmv/uniform_test.go
@@ -8,7 +8,7 @@ import (
"math"
"testing"
- "gonum.org/v1/gonum/bound"
+ "gonum.org/v1/gonum/spatial/r1"
)
func TestUniformEntropy(t *testing.T) {
@@ -17,11 +17,11 @@ func TestUniformEntropy(t *testing.T) {
Entropy float64
}{
{
- NewUniform([]bound.Bound{{0, 1}, {0, 1}}, nil),
+ NewUniform([]r1.Interval{{0, 1}, {0, 1}}, nil),
0,
},
{
- NewUniform([]bound.Bound{{-1, 3}, {2, 8}, {-5, -3}}, nil),
+ NewUniform([]r1.Interval{{-1, 3}, {2, 8}, {-5, -3}}, nil),
math.Log(48),
},
} {

MODIFY
stat/samplemv/sample_test.go
stat/samplemv/sample_test.go
@@ -10,9 +10,9 @@ import (
"golang.org/x/exp/rand"
- "gonum.org/v1/gonum/bound"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
+ "gonum.org/v1/gonum/spatial/r1"
"gonum.org/v1/gonum/stat"
"gonum.org/v1/gonum/stat/distmv"
)
@@ -27,8 +27,8 @@ func TestLatinHypercube(t *testing.T) {
src := rand.New(rand.NewSource(1))
for _, nSamples := range []int{1, 2, 5, 10, 20} {
for _, dist := range []lhDist{
- distmv.NewUniform([]bound.Bound{{Min: 0, Max: 3}}, src),
- distmv.NewUniform([]bound.Bound{{Min: 0, Max: 3}, {Min: -1, Max: 5}, {Min: -4, Max: -1}}, src),
+ distmv.NewUniform([]r1.Interval{{Min: 0, Max: 3}}, src),
+ distmv.NewUniform([]r1.Interval{{Min: 0, Max: 3}, {Min: -1, Max: 5}, {Min: -4, Max: -1}}, src),
} {
dim := dist.Dim()
batch := mat.NewDense(nSamples, dim, nil)
@@ -93,7 +93,7 @@ func TestRejection(t *testing.T) {
src := rand.New(rand.NewSource(1))
// Test by finding the expected value of a uniform.
dim := 3
- bounds := make([]bound.Bound, dim)
+ bounds := make([]r1.Interval, dim)
for i := 0; i < dim; i++ {
min := src.NormFloat64()
max := src.NormFloat64()

spatial/r1: import and rename from bound

* spatial/r1: import and rename from bound

Mechanically generated with:

 $> gomvpkg -from gonum.org/v1/gonum/bound -to gonum.org/v1/gonum/spatial/r1 -vcs_mv_cmd "git mv {{.Src}} {{.Dst}}"

Fixes #956.