all: replace internal rand shim with math/rand/v2

This commit is contained in:
Dan Kortschak
2025-01-02 12:07:22 +10:30
parent cf3307fa63
commit bc349ecfab
345 changed files with 1165 additions and 1214 deletions

View File

@@ -7,6 +7,7 @@ package path
import (
"fmt"
"math"
"math/rand/v2"
"reflect"
"slices"
"testing"
@@ -15,7 +16,6 @@ import (
"gonum.org/v1/gonum/graph/graphs/gen"
"gonum.org/v1/gonum/graph/simple"
"gonum.org/v1/gonum/internal/order"
"gonum.org/v1/gonum/internal/rand"
)
var shortestTests = []struct {
@@ -35,7 +35,7 @@ func TestShortestAlts(t *testing.T) {
for _, test := range shortestTests {
t.Run(fmt.Sprintf("AllTo_%d×%d|%v", test.n, test.d, test.p), func(t *testing.T) {
g := simple.NewDirectedGraph()
gen.SmallWorldsBB(g, test.n, test.d, test.p, rand.New(rand.NewSource(test.seed)))
gen.SmallWorldsBB(g, test.n, test.d, test.p, rand.New(rand.NewPCG(test.seed, test.seed)))
all := allShortest(DijkstraAllPaths(g))
for uid := int64(0); uid < int64(test.n); uid++ {
@@ -82,7 +82,7 @@ func TestAllShortest(t *testing.T) {
for _, test := range shortestTests {
t.Run(fmt.Sprintf("AllBetween_%d×%d|%v", test.n, test.d, test.p), func(t *testing.T) {
g := simple.NewDirectedGraph()
gen.SmallWorldsBB(g, test.n, test.d, test.p, rand.New(rand.NewSource(test.seed)))
gen.SmallWorldsBB(g, test.n, test.d, test.p, rand.New(rand.NewPCG(test.seed, test.seed)))
p := DijkstraAllPaths(g)
for uid := int64(0); uid < int64(test.n); uid++ {
@@ -221,7 +221,7 @@ var shortestBenchmarks = []struct {
func BenchmarkShortestAlts(b *testing.B) {
for _, bench := range shortestBenchmarks {
g := simple.NewDirectedGraph()
gen.SmallWorldsBB(g, bench.n, bench.d, bench.p, rand.New(rand.NewSource(bench.seed)))
gen.SmallWorldsBB(g, bench.n, bench.d, bench.p, rand.New(rand.NewPCG(bench.seed, bench.seed)))
// Find the widest path set.
var (
@@ -282,7 +282,7 @@ func BenchmarkAllShortest(b *testing.B) {
for _, bench := range shortestBenchmarks {
for _, f := range shortestPathAlgs {
g := simple.NewDirectedGraph()
gen.SmallWorldsBB(g, bench.n, bench.d, bench.p, rand.New(rand.NewSource(bench.seed)))
gen.SmallWorldsBB(g, bench.n, bench.d, bench.p, rand.New(rand.NewPCG(bench.seed, bench.seed)))
p := f.fn(g)
// Find the widest path set.