mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 15:16:59 +08:00
all: replace internal rand shim with math/rand/v2
This commit is contained in:
@@ -6,10 +6,10 @@ package optimize
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"sort"
|
||||
|
||||
"gonum.org/v1/gonum/floats"
|
||||
"gonum.org/v1/gonum/internal/rand"
|
||||
"gonum.org/v1/gonum/mat"
|
||||
"gonum.org/v1/gonum/stat/distmv"
|
||||
)
|
||||
|
@@ -7,10 +7,10 @@ package optimize
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"testing"
|
||||
|
||||
"gonum.org/v1/gonum/floats"
|
||||
"gonum.org/v1/gonum/internal/rand"
|
||||
"gonum.org/v1/gonum/mat"
|
||||
"gonum.org/v1/gonum/optimize/functions"
|
||||
)
|
||||
@@ -201,7 +201,7 @@ func cmaTestCases() []cmaTestCase {
|
||||
func TestCmaEsChol(t *testing.T) {
|
||||
t.Parallel()
|
||||
for i, test := range cmaTestCases() {
|
||||
src := rand.New(rand.NewSource(1))
|
||||
src := rand.New(rand.NewPCG(1, 1))
|
||||
method := test.method
|
||||
method.Src = src
|
||||
initX := test.initX
|
||||
|
@@ -5,10 +5,10 @@
|
||||
package lp
|
||||
|
||||
import (
|
||||
"math/rand/v2"
|
||||
"testing"
|
||||
|
||||
"gonum.org/v1/gonum/floats/scalar"
|
||||
"gonum.org/v1/gonum/internal/rand"
|
||||
"gonum.org/v1/gonum/mat"
|
||||
)
|
||||
|
||||
@@ -129,7 +129,7 @@ func TestSimplex(t *testing.T) {
|
||||
testSimplex(t, test.initialBasic, test.c, test.A, test.b, convergenceTol)
|
||||
}
|
||||
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
rnd := rand.New(rand.NewPCG(1, 1))
|
||||
// Randomized tests
|
||||
testRandomSimplex(t, 20000, 0.2, 10, rnd)
|
||||
testRandomSimplex(t, 20000, 0, 10, rnd)
|
||||
@@ -140,8 +140,8 @@ func TestSimplex(t *testing.T) {
|
||||
func testRandomSimplex(t *testing.T, nTest int, pZero float64, maxN int, rnd *rand.Rand) {
|
||||
// Try a bunch of random LPs
|
||||
for i := 0; i < nTest; i++ {
|
||||
n := rnd.Intn(maxN) + 2 // n must be at least two.
|
||||
m := rnd.Intn(n-1) + 1 // m must be between 1 and n
|
||||
n := rnd.IntN(maxN) + 2 // n must be at least two.
|
||||
m := rnd.IntN(n-1) + 1 // m must be between 1 and n
|
||||
if m == 0 || n == 0 {
|
||||
continue
|
||||
}
|
||||
|
@@ -5,17 +5,17 @@
|
||||
package optimize
|
||||
|
||||
import (
|
||||
"math/rand/v2"
|
||||
"testing"
|
||||
|
||||
"gonum.org/v1/gonum/floats"
|
||||
"gonum.org/v1/gonum/internal/rand"
|
||||
"gonum.org/v1/gonum/mat"
|
||||
"gonum.org/v1/gonum/optimize/functions"
|
||||
)
|
||||
|
||||
func TestListSearch(t *testing.T) {
|
||||
t.Parallel()
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
rnd := rand.New(rand.NewPCG(1, 1))
|
||||
for cas, test := range []struct {
|
||||
r, c int
|
||||
shortEvals int
|
||||
@@ -131,7 +131,7 @@ func TestListSearch(t *testing.T) {
|
||||
for floats.MinIdx(fs[:evals]) != floats.MinIdx(fs[:evals+concurrent]) {
|
||||
// Swap the minimum index with a random element.
|
||||
minIdxFirst := floats.MinIdx(fs[:evals+concurrent])
|
||||
new := rnd.Intn(evals)
|
||||
new := rnd.IntN(evals)
|
||||
swapSamples(locs, fs, minIdxFirst, new)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user