Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line numberDiff line numberDiff line change
Expand Up@@ -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=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
)

Expand DownExpand Up@@ -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)
Expand All@@ -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)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
Comment thread
Juneezee marked this conversation as resolved.

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,18 +7,18 @@ 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"
)

// 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.
Expand DownExpand Up@@ -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 {
Expand All@@ -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")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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 {
Expand DownExpand Up@@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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.
Expand Down
Loading