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 community
import (
"fmt"
"math"
"math/rand/v2"
"reflect"
"slices"
"testing"
@@ -16,7 +17,6 @@ import (
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/simple"
"gonum.org/v1/gonum/internal/order"
"gonum.org/v1/gonum/internal/rand"
)
var communityUndirectedMultiplexQTests = []struct {
@@ -295,7 +295,7 @@ tests:
continue
}
rnd := rand.New(rand.NewSource(1)).Intn
rnd := rand.New(rand.NewPCG(1, 1)).IntN
for _, structure := range test.structures {
communityOf := make(map[int64]int)
communities := make([][]graph.Node, len(structure.memberships))
@@ -557,7 +557,7 @@ func TestLouvainMultiplex(t *testing.T) {
)
// Modularize is randomised so we do this to
// ensure the level tests are consistent.
src := rand.New(rand.NewSource(1))
src := rand.New(rand.NewPCG(1, 1))
for i := 0; i < louvainIterations; i++ {
r := ModularizeMultiplex(g, weights, nil, true, src).(*ReducedUndirectedMultiplex)
if q := floats.Sum(QMultiplex(r, nil, weights, nil)); q > bestQ || math.IsNaN(q) {
@@ -658,7 +658,7 @@ func TestNonContiguousWeightedUndirectedMultiplex(t *testing.T) {
}
func BenchmarkLouvainMultiplex(b *testing.B) {
src := rand.New(rand.NewSource(1))
src := rand.New(rand.NewPCG(1, 1))
for i := 0; i < b.N; i++ {
ModularizeMultiplex(UndirectedLayers{dupGraph}, nil, nil, true, src)
}