diff --git a/go.mod b/go.mod index 33abc65e..480fb9ce 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( codeberg.org/go-pdf/fpdf v0.10.0 git.sr.ht/~sbinet/gg v0.6.0 github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/image v0.25.0 gonum.org/v1/gonum v0.16.0 rsc.io/pdf v0.1.1 diff --git a/go.sum b/go.sum index a193529b..5200c7ee 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= diff --git a/gob/gob_test.go b/gob/gob_test.go index 21f72fed..1067d21e 100644 --- a/gob/gob_test.go +++ b/gob/gob_test.go @@ -8,11 +8,10 @@ import ( "bytes" "encoding/gob" "image/color" + "math/rand/v2" "os" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" _ "gonum.org/v1/plot/gob" "gonum.org/v1/plot/plotter" @@ -25,7 +24,7 @@ func init() { } func TestPersistency(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Get some random points n := 15 diff --git a/palette/moreland/luminance_test.go b/palette/moreland/luminance_test.go index 6e4c0312..7ab19547 100644 --- a/palette/moreland/luminance_test.go +++ b/palette/moreland/luminance_test.go @@ -7,10 +7,9 @@ package moreland import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/gonum/floats/scalar" ) @@ -151,10 +150,10 @@ func BenchmarkLuminance_At(b *testing.B) { b.Fatal(err) } p.SetMax(1) - rand.Seed(1) + rng := rand.New(rand.NewPCG(1, 1)) b.Run(fmt.Sprintf("%d controls", n), func(b *testing.B) { for i := 0; i < b.N; i++ { - if _, err := p.At(rand.Float64()); err != nil { + if _, err := p.At(rng.Float64()); err != nil { b.Fatal(err) } } diff --git a/palette/moreland/smooth_test.go b/palette/moreland/smooth_test.go index 06e7ab90..8cff8409 100644 --- a/palette/moreland/smooth_test.go +++ b/palette/moreland/smooth_test.go @@ -7,11 +7,10 @@ package moreland import ( "image/color" "math" + "math/rand/v2" "strings" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot/palette" ) @@ -177,7 +176,6 @@ func testRGB(t *testing.T, i int, label string, c1 color.Color, c2 [3]float64) { } func TestSmoothDiverging_At(t *testing.T) { - start := msh{M: 80, S: 1.08, H: -1.1} end := msh{M: 80, S: 1.08, H: 0.5} p := newSmoothDiverging(start, end, 88) @@ -199,9 +197,9 @@ func TestSmoothDiverging_At(t *testing.T) { func BenchmarkSmoothDiverging_At(b *testing.B) { p := SmoothBlueRed() p.SetMax(1.0000000001) - rand.Seed(1) + rng := rand.New(rand.NewPCG(1, 1)) for i := 0; i < b.N; i++ { - if _, err := p.At(rand.Float64()); err != nil { + if _, err := p.At(rng.Float64()); err != nil { b.Fatal(err) } } diff --git a/plotter/barchart_example_test.go b/plotter/barchart_example_test.go index d73a7a26..8d83bff4 100644 --- a/plotter/barchart_example_test.go +++ b/plotter/barchart_example_test.go @@ -7,10 +7,9 @@ package plotter_test import ( "image/color" "log" + "math/rand/v2" "runtime" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" @@ -158,7 +157,7 @@ func ExampleBarChart() { // This example shows a bar chart with both positive and negative values. func ExampleBarChart_positiveNegative() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Create random data points between -1 and 1. const n = 6 diff --git a/plotter/boxplot_example_test.go b/plotter/boxplot_example_test.go index 6a31e6d9..d3812f25 100644 --- a/plotter/boxplot_example_test.go +++ b/plotter/boxplot_example_test.go @@ -8,8 +8,7 @@ import ( "fmt" "image/color" "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -17,7 +16,7 @@ import ( ) func ExampleBoxPlot() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Create the sample data. const n = 100 diff --git a/plotter/bubbles_example_test.go b/plotter/bubbles_example_test.go index ae820c62..4febe20f 100644 --- a/plotter/bubbles_example_test.go +++ b/plotter/bubbles_example_test.go @@ -8,8 +8,7 @@ import ( "image/color" "log" "math" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -21,7 +20,7 @@ import ( // Each point is plotted with a different radius size depending on // external criteria. func ExampleScatter_bubbles() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomTriples returns some random but correlated x, y, z triples randomTriples := func(n int) plotter.XYZs { diff --git a/plotter/contour_example_test.go b/plotter/contour_example_test.go index bac84556..ab5a9fad 100644 --- a/plotter/contour_example_test.go +++ b/plotter/contour_example_test.go @@ -7,11 +7,10 @@ package plotter_test import ( "log" "math" + "math/rand/v2" "runtime" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/gonum/mat" "gonum.org/v1/plot" "gonum.org/v1/plot/cmpimg" @@ -21,7 +20,7 @@ import ( ) func ExampleContour() { - rnd := rand.New(rand.NewSource(1234)) + rnd := rand.New(rand.NewPCG(1234, 1234)) const stddev = 2 data := make([]float64, 6400) diff --git a/plotter/contour_test.go b/plotter/contour_test.go index b412c14e..1803d5d9 100644 --- a/plotter/contour_test.go +++ b/plotter/contour_test.go @@ -8,13 +8,12 @@ import ( "flag" "fmt" "math" + "math/rand/v2" "reflect" "slices" "sort" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/gonum/mat" "gonum.org/v1/plot" "gonum.org/v1/plot/palette" @@ -74,7 +73,7 @@ func TestHeatMapWithContour(t *testing.T) { } func TestComplexContours(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) if !*visualDebug { return @@ -121,7 +120,7 @@ func BenchmarkComplexContour32(b *testing.B) { complexContourBench(32, b) } var cp map[float64][]vg.Path func complexContourBench(noise float64, b *testing.B) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) data := make([]float64, 6400) for i := range data { diff --git a/plotter/errbars_example_test.go b/plotter/errbars_example_test.go index 60283e32..e3391ca2 100644 --- a/plotter/errbars_example_test.go +++ b/plotter/errbars_example_test.go @@ -6,8 +6,7 @@ package plotter_test import ( "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -16,7 +15,7 @@ import ( // ExampleErrors draws points and error bars. func ExampleErrors() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) randomError := func(n int) plotter.Errors { err := make(plotter.Errors, n) diff --git a/plotter/filledLine_example_test.go b/plotter/filledLine_example_test.go index 2be22156..b2e25fca 100644 --- a/plotter/filledLine_example_test.go +++ b/plotter/filledLine_example_test.go @@ -7,15 +7,15 @@ package plotter_test import ( "image/color" "log" - - "golang.org/x/exp/rand" + "math/rand/v2" + "runtime" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" ) func ExampleLine_filledLine() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomPoints returns some random x, y points // with some interesting kind of trend. @@ -46,7 +46,7 @@ func ExampleLine_filledLine() { p.Add(filled) - err = p.Save(200, 200, "testdata/filledLine.png") + err = p.Save(200, 200, "testdata/filledLine_"+runtime.GOARCH+".png") if err != nil { log.Panic(err) } diff --git a/plotter/filledLine_test.go b/plotter/filledLine_test.go index 26430b3e..573628cd 100644 --- a/plotter/filledLine_test.go +++ b/plotter/filledLine_test.go @@ -7,10 +7,10 @@ package plotter_test import ( "image/color" "log" + "math/rand/v2" + "runtime" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/cmpimg" "gonum.org/v1/plot/plotter" @@ -18,7 +18,7 @@ import ( // See https://github.com/gonum/plot/issues/488 func clippedFilledLine() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomPoints returns some random x, y points // with some interesting kind of trend. @@ -49,8 +49,8 @@ func clippedFilledLine() { p.Add(filled) // testing clipping - p.X.Min, p.X.Max = 1, 3 - p.Y.Max = -1 + p.X.Min, p.X.Max = 1, 3.5 + p.Y.Max = 4 err = p.Save(200, 200, "testdata/clippedFilledLine.png") if err != nil { @@ -59,6 +59,6 @@ func clippedFilledLine() { } func TestFilledLine(t *testing.T) { - cmpimg.CheckPlot(ExampleLine_filledLine, t, "filledLine.png") + cmpimg.CheckPlot(ExampleLine_filledLine, t, "filledLine_"+runtime.GOARCH+".png") cmpimg.CheckPlot(clippedFilledLine, t, "clippedFilledLine.png") } diff --git a/plotter/histogram_example_test.go b/plotter/histogram_example_test.go index cc233afb..f4971ad7 100644 --- a/plotter/histogram_example_test.go +++ b/plotter/histogram_example_test.go @@ -8,8 +8,7 @@ import ( "image/color" "log" "math" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -18,7 +17,7 @@ import ( // An example of making a histogram. func ExampleHistogram() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // stdNorm returns the probability of drawing a // value from a standard normal distribution. diff --git a/plotter/quartile_example_test.go b/plotter/quartile_example_test.go index 65129ac4..37b4d0b5 100644 --- a/plotter/quartile_example_test.go +++ b/plotter/quartile_example_test.go @@ -6,8 +6,7 @@ package plotter_test import ( "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -15,7 +14,7 @@ import ( ) func ExampleQuartPlot() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Create the example data. n := 100 diff --git a/plotter/scatterColor_example_test.go b/plotter/scatterColor_example_test.go index 982d4576..59806a37 100644 --- a/plotter/scatterColor_example_test.go +++ b/plotter/scatterColor_example_test.go @@ -8,10 +8,9 @@ import ( "fmt" "log" "math" + "math/rand/v2" "os" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/palette/moreland" "gonum.org/v1/plot/plotter" @@ -24,7 +23,7 @@ import ( // Each point is plotted with a different color depending on // external criteria. func ExampleScatter_color() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomTriples returns some random but correlated x, y, z triples randomTriples := func(n int) plotter.XYZs { @@ -76,7 +75,8 @@ func ExampleScatter_color() { d := (z - minZ) / (maxZ - minZ) rng := maxZ - minZ k := d*rng + minZ - c, err := colors.At(k) + // Clamp k to avoid potential overflow due to floating point error. + c, err := colors.At(min(k, colors.Max())) if err != nil { log.Panic(err) } diff --git a/plotter/scatter_example_test.go b/plotter/scatter_example_test.go index 9d354bc9..b0a80201 100644 --- a/plotter/scatter_example_test.go +++ b/plotter/scatter_example_test.go @@ -7,8 +7,7 @@ package plotter_test import ( "image/color" "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -19,7 +18,7 @@ import ( // ExampleScatter draws some scatter points, a line, // and a line with points. func ExampleScatter() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomPoints returns some random x, y points // with some interesting kind of trend. diff --git a/plotter/step_example_test.go b/plotter/step_example_test.go index 8c4a0de9..f9d6de16 100644 --- a/plotter/step_example_test.go +++ b/plotter/step_example_test.go @@ -7,8 +7,7 @@ package plotter_test import ( "image/color" "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -17,7 +16,7 @@ import ( ) func ExampleLine_stepLine() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // randomPoints returns some random x, y points // with some interesting kind of trend. diff --git a/plotter/testdata/barChart_positiveNegative_golden.png b/plotter/testdata/barChart_positiveNegative_golden.png index b5365204..245390c1 100644 Binary files a/plotter/testdata/barChart_positiveNegative_golden.png and b/plotter/testdata/barChart_positiveNegative_golden.png differ diff --git a/plotter/testdata/bubbles_golden.png b/plotter/testdata/bubbles_golden.png index 531d2ed1..658ff1c3 100644 Binary files a/plotter/testdata/bubbles_golden.png and b/plotter/testdata/bubbles_golden.png differ diff --git a/plotter/testdata/clippedFilledLine_golden.png b/plotter/testdata/clippedFilledLine_golden.png index f959a4fe..85bd9f97 100644 Binary files a/plotter/testdata/clippedFilledLine_golden.png and b/plotter/testdata/clippedFilledLine_golden.png differ diff --git a/plotter/testdata/contour_amd64_golden.png b/plotter/testdata/contour_amd64_golden.png index efaad809..3c72e854 100644 Binary files a/plotter/testdata/contour_amd64_golden.png and b/plotter/testdata/contour_amd64_golden.png differ diff --git a/plotter/testdata/contour_arm64_golden.png b/plotter/testdata/contour_arm64_golden.png index 76034f6c..668b2339 100644 Binary files a/plotter/testdata/contour_arm64_golden.png and b/plotter/testdata/contour_arm64_golden.png differ diff --git a/plotter/testdata/errorBars_golden.png b/plotter/testdata/errorBars_golden.png index ddab3e65..50431c85 100644 Binary files a/plotter/testdata/errorBars_golden.png and b/plotter/testdata/errorBars_golden.png differ diff --git a/plotter/testdata/filledLine_amd64_golden.png b/plotter/testdata/filledLine_amd64_golden.png new file mode 100644 index 00000000..7b457474 Binary files /dev/null and b/plotter/testdata/filledLine_amd64_golden.png differ diff --git a/plotter/testdata/filledLine_arm64_golden.png b/plotter/testdata/filledLine_arm64_golden.png new file mode 100644 index 00000000..6d055308 Binary files /dev/null and b/plotter/testdata/filledLine_arm64_golden.png differ diff --git a/plotter/testdata/filledLine_golden.png b/plotter/testdata/filledLine_golden.png deleted file mode 100644 index e2ebf27c..00000000 Binary files a/plotter/testdata/filledLine_golden.png and /dev/null differ diff --git a/plotter/testdata/groupedBoxPlot_golden.png b/plotter/testdata/groupedBoxPlot_golden.png index 41abab82..3e4fd47b 100644 Binary files a/plotter/testdata/groupedBoxPlot_golden.png and b/plotter/testdata/groupedBoxPlot_golden.png differ diff --git a/plotter/testdata/groupedQuartPlot_golden.png b/plotter/testdata/groupedQuartPlot_golden.png index 382fc67b..9202a8fa 100644 Binary files a/plotter/testdata/groupedQuartPlot_golden.png and b/plotter/testdata/groupedQuartPlot_golden.png differ diff --git a/plotter/testdata/histogram_golden.png b/plotter/testdata/histogram_golden.png index bd2bdf8d..c383e34d 100644 Binary files a/plotter/testdata/histogram_golden.png and b/plotter/testdata/histogram_golden.png differ diff --git a/plotter/testdata/horizontalBoxPlot_golden.png b/plotter/testdata/horizontalBoxPlot_golden.png index 04d0744f..599bfa37 100644 Binary files a/plotter/testdata/horizontalBoxPlot_golden.png and b/plotter/testdata/horizontalBoxPlot_golden.png differ diff --git a/plotter/testdata/horizontalQuartPlot_golden.png b/plotter/testdata/horizontalQuartPlot_golden.png index 5508d407..07d5003c 100644 Binary files a/plotter/testdata/horizontalQuartPlot_golden.png and b/plotter/testdata/horizontalQuartPlot_golden.png differ diff --git a/plotter/testdata/scatterColor_golden.png b/plotter/testdata/scatterColor_golden.png index 6a878a41..913b965d 100644 Binary files a/plotter/testdata/scatterColor_golden.png and b/plotter/testdata/scatterColor_golden.png differ diff --git a/plotter/testdata/scatter_golden.png b/plotter/testdata/scatter_golden.png index 1dc39bae..ca33c63d 100644 Binary files a/plotter/testdata/scatter_golden.png and b/plotter/testdata/scatter_golden.png differ diff --git a/plotter/testdata/step_golden.png b/plotter/testdata/step_golden.png index 0e0a87aa..dd093cc1 100644 Binary files a/plotter/testdata/step_golden.png and b/plotter/testdata/step_golden.png differ diff --git a/plotter/testdata/verticalBoxPlot_golden.png b/plotter/testdata/verticalBoxPlot_golden.png index 861233bc..102f947e 100644 Binary files a/plotter/testdata/verticalBoxPlot_golden.png and b/plotter/testdata/verticalBoxPlot_golden.png differ diff --git a/plotter/testdata/verticalQuartPlot_golden.png b/plotter/testdata/verticalQuartPlot_golden.png index 6853cd40..9178d41d 100644 Binary files a/plotter/testdata/verticalQuartPlot_golden.png and b/plotter/testdata/verticalQuartPlot_golden.png differ diff --git a/plotter/timeseries_example_test.go b/plotter/timeseries_example_test.go index 1533154d..8caed8b8 100644 --- a/plotter/timeseries_example_test.go +++ b/plotter/timeseries_example_test.go @@ -7,10 +7,9 @@ package plotter_test import ( "image/color" "log" + "math/rand/v2" "time" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" @@ -19,7 +18,7 @@ import ( // Example_timeSeries draws a time series. func Example_timeSeries() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // xticks defines how we convert and display time.Time values. xticks := plot.TimeTicks{Format: "2006-01-02\n15:04"} diff --git a/plotutil/errorpoints_example_test.go b/plotutil/errorpoints_example_test.go index 3b7e7d36..903ad2e0 100644 --- a/plotutil/errorpoints_example_test.go +++ b/plotutil/errorpoints_example_test.go @@ -5,7 +5,7 @@ package plotutil_test import ( - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -13,7 +13,7 @@ import ( ) func ExampleErrorPoints() { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Get some random data. n, m := 5, 10 diff --git a/plotutil/main.go b/plotutil/main.go index f81905a0..0c16cfc2 100644 --- a/plotutil/main.go +++ b/plotutil/main.go @@ -8,7 +8,7 @@ package main import ( - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" @@ -73,7 +73,7 @@ func drawJpg(name string, mkplot func() *plot.Plot) { // Example_errpoints draws some error points. func Example_errpoints() *plot.Plot { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) // Get some random data. n, m := 5, 10