Skip to content

Commit 6cdb326

Browse files
authored
all: migrate to math/rand/v2
1 parent 82c684a commit 6cdb326

40 files changed

+49
-67
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
codeberg.org/go-pdf/fpdf v0.10.0
1010
git.sr.ht/~sbinet/gg v0.6.0
1111
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b
12-
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
1312
golang.org/x/image v0.25.0
1413
gonum.org/v1/gonum v0.16.0
1514
rsc.io/pdf v0.1.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
2828
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2929
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
3030
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
31-
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
32-
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
3331
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
3432
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
3533
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=

gob/gob_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import (
88
"bytes"
99
"encoding/gob"
1010
"image/color"
11+
"math/rand/v2"
1112
"os"
1213
"testing"
1314

14-
"golang.org/x/exp/rand"
15-
1615
"gonum.org/v1/plot"
1716
_ "gonum.org/v1/plot/gob"
1817
"gonum.org/v1/plot/plotter"
@@ -25,7 +24,7 @@ func init() {
2524
}
2625

2726
func TestPersistency(t *testing.T) {
28-
rnd := rand.New(rand.NewSource(1))
27+
rnd := rand.New(rand.NewPCG(1, 1))
2928

3029
// Get some random points
3130
n := 15

palette/moreland/luminance_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ package moreland
77
import (
88
"fmt"
99
"image/color"
10+
"math/rand/v2"
1011
"testing"
1112

12-
"golang.org/x/exp/rand"
13-
1413
"gonum.org/v1/gonum/floats/scalar"
1514
)
1615

@@ -151,10 +150,10 @@ func BenchmarkLuminance_At(b *testing.B) {
151150
b.Fatal(err)
152151
}
153152
p.SetMax(1)
154-
rand.Seed(1)
153+
rng := rand.New(rand.NewPCG(1, 1))
155154
b.Run(fmt.Sprintf("%d controls", n), func(b *testing.B) {
156155
for i := 0; i < b.N; i++ {
157-
if _, err := p.At(rand.Float64()); err != nil {
156+
if _, err := p.At(rng.Float64()); err != nil {
158157
b.Fatal(err)
159158
}
160159
}

palette/moreland/smooth_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ package moreland
77
import (
88
"image/color"
99
"math"
10+
"math/rand/v2"
1011
"strings"
1112
"testing"
1213

13-
"golang.org/x/exp/rand"
14-
1514
"gonum.org/v1/plot/palette"
1615
)
1716

@@ -177,7 +176,6 @@ func testRGB(t *testing.T, i int, label string, c1 color.Color, c2 [3]float64) {
177176
}
178177

179178
func TestSmoothDiverging_At(t *testing.T) {
180-
181179
start := msh{M: 80, S: 1.08, H: -1.1}
182180
end := msh{M: 80, S: 1.08, H: 0.5}
183181
p := newSmoothDiverging(start, end, 88)
@@ -199,9 +197,9 @@ func TestSmoothDiverging_At(t *testing.T) {
199197
func BenchmarkSmoothDiverging_At(b *testing.B) {
200198
p := SmoothBlueRed()
201199
p.SetMax(1.0000000001)
202-
rand.Seed(1)
200+
rng := rand.New(rand.NewPCG(1, 1))
203201
for i := 0; i < b.N; i++ {
204-
if _, err := p.At(rand.Float64()); err != nil {
202+
if _, err := p.At(rng.Float64()); err != nil {
205203
b.Fatal(err)
206204
}
207205
}

plotter/barchart_example_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ package plotter_test
77
import (
88
"image/color"
99
"log"
10+
"math/rand/v2"
1011
"runtime"
1112

12-
"golang.org/x/exp/rand"
13-
1413
"gonum.org/v1/plot"
1514
"gonum.org/v1/plot/plotter"
1615
"gonum.org/v1/plot/vg"
@@ -158,7 +157,7 @@ func ExampleBarChart() {
158157

159158
// This example shows a bar chart with both positive and negative values.
160159
func ExampleBarChart_positiveNegative() {
161-
rnd := rand.New(rand.NewSource(1))
160+
rnd := rand.New(rand.NewPCG(1, 1))
162161

163162
// Create random data points between -1 and 1.
164163
const n = 6

plotter/boxplot_example_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ import (
88
"fmt"
99
"image/color"
1010
"log"
11-
12-
"golang.org/x/exp/rand"
11+
"math/rand/v2"
1312

1413
"gonum.org/v1/plot"
1514
"gonum.org/v1/plot/plotter"
1615
"gonum.org/v1/plot/vg"
1716
)
1817

1918
func ExampleBoxPlot() {
20-
rnd := rand.New(rand.NewSource(1))
19+
rnd := rand.New(rand.NewPCG(1, 1))
2120

2221
// Create the sample data.
2322
const n = 100

plotter/bubbles_example_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"image/color"
99
"log"
1010
"math"
11-
12-
"golang.org/x/exp/rand"
11+
"math/rand/v2"
1312

1413
"gonum.org/v1/plot"
1514
"gonum.org/v1/plot/plotter"
@@ -21,7 +20,7 @@ import (
2120
// Each point is plotted with a different radius size depending on
2221
// external criteria.
2322
func ExampleScatter_bubbles() {
24-
rnd := rand.New(rand.NewSource(1))
23+
rnd := rand.New(rand.NewPCG(1, 1))
2524

2625
// randomTriples returns some random but correlated x, y, z triples
2726
randomTriples := func(n int) plotter.XYZs {

plotter/contour_example_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ package plotter_test
77
import (
88
"log"
99
"math"
10+
"math/rand/v2"
1011
"runtime"
1112
"testing"
1213

13-
"golang.org/x/exp/rand"
14-
1514
"gonum.org/v1/gonum/mat"
1615
"gonum.org/v1/plot"
1716
"gonum.org/v1/plot/cmpimg"
@@ -21,7 +20,7 @@ import (
2120
)
2221

2322
func ExampleContour() {
24-
rnd := rand.New(rand.NewSource(1234))
23+
rnd := rand.New(rand.NewPCG(1234, 1234))
2524

2625
const stddev = 2
2726
data := make([]float64, 6400)

plotter/contour_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import (
88
"flag"
99
"fmt"
1010
"math"
11+
"math/rand/v2"
1112
"reflect"
1213
"slices"
1314
"sort"
1415
"testing"
1516

16-
"golang.org/x/exp/rand"
17-
1817
"gonum.org/v1/gonum/mat"
1918
"gonum.org/v1/plot"
2019
"gonum.org/v1/plot/palette"
@@ -74,7 +73,7 @@ func TestHeatMapWithContour(t *testing.T) {
7473
}
7574

7675
func TestComplexContours(t *testing.T) {
77-
rnd := rand.New(rand.NewSource(1))
76+
rnd := rand.New(rand.NewPCG(1, 1))
7877

7978
if !*visualDebug {
8079
return
@@ -121,7 +120,7 @@ func BenchmarkComplexContour32(b *testing.B) { complexContourBench(32, b) }
121120
var cp map[float64][]vg.Path
122121

123122
func complexContourBench(noise float64, b *testing.B) {
124-
rnd := rand.New(rand.NewSource(1))
123+
rnd := rand.New(rand.NewPCG(1, 1))
125124

126125
data := make([]float64, 6400)
127126
for i := range data {

0 commit comments

Comments
 (0)