diff --git a/go.mod b/go.mod index ce17800..2f8a6ad 100644 --- a/go.mod +++ b/go.mod @@ -3,20 +3,17 @@ module gonum.org/v1/exp go 1.25.0 require ( - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c - gonum.org/v1/gonum v0.15.1 - gonum.org/v1/plot v0.15.1 + gonum.org/v1/gonum v0.17.0 + gonum.org/v1/plot v0.17.0 ) require ( - codeberg.org/go-fonts/liberation v0.5.0 // indirect - codeberg.org/go-latex/latex v0.1.0 // indirect - codeberg.org/go-pdf/fpdf v0.10.0 // indirect - git.sr.ht/~sbinet/gg v0.6.0 // indirect + codeberg.org/go-fonts/liberation v0.6.0 // indirect + codeberg.org/go-latex/latex v0.3.0 // indirect + codeberg.org/go-pdf/fpdf v0.12.0 // indirect + git.sr.ht/~sbinet/gg v0.8.0 // indirect github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect - github.com/campoy/embedmd v1.0.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/image v0.40.0 // indirect golang.org/x/text v0.37.0 // indirect golang.org/x/tools v0.45.0 // indirect diff --git a/go.sum b/go.sum index c0edbae..51e8124 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,31 @@ codeberg.org/go-fonts/dejavu v0.4.0 h1:2yn58Vkh4CFK3ipacWUAIE3XVBGNa0y1bc95Bmfx91I= codeberg.org/go-fonts/dejavu v0.4.0/go.mod h1:abni088lmhQJvso2Lsb7azCKzwkfcnttl6tL1UTWKzg= -codeberg.org/go-fonts/latin-modern v0.4.0 h1:vkRCc1y3whKA7iL9Ep0fSGVuJfqjix0ica9UflHORO8= -codeberg.org/go-fonts/latin-modern v0.4.0/go.mod h1:BF68mZznJ9QHn+hic9ks2DaFl4sR5YhfM6xTYaP9vNw= -codeberg.org/go-fonts/liberation v0.5.0 h1:SsKoMO1v1OZmzkG2DY+7ZkCL9U+rrWI09niOLfQ5Bo0= -codeberg.org/go-fonts/liberation v0.5.0/go.mod h1:zS/2e1354/mJ4pGzIIaEtm/59VFCFnYC7YV6YdGl5GU= -codeberg.org/go-latex/latex v0.1.0 h1:hoGO86rIbWVyjtlDLzCqZPjNykpWQ9YuTZqAzPcfL3c= -codeberg.org/go-latex/latex v0.1.0/go.mod h1:LA0q/AyWIYrqVd+A9Upkgsb+IqPcmSTKc9Dny04MHMw= -codeberg.org/go-pdf/fpdf v0.10.0 h1:u+w669foDDx5Ds43mpiiayp40Ov6sZalgcPMDBcZRd4= -codeberg.org/go-pdf/fpdf v0.10.0/go.mod h1:Y0DGRAdZ0OmnZPvjbMp/1bYxmIPxm0ws4tfoPOc4LjU= +codeberg.org/go-fonts/latin-modern v0.5.0 h1:5vzaHjM+3uTRHhqQUuTZ/4FoVZkqXufyuKB9SdpLGp0= +codeberg.org/go-fonts/latin-modern v0.5.0/go.mod h1:p8kFovLhQWuvorvlEjhjCp/3NZ06u7h23LvuLwQFK84= +codeberg.org/go-fonts/liberation v0.6.0 h1:15Gh6SdwYve22CWCm9jYpVpRuaTh726av2TgHTHvAtQ= +codeberg.org/go-fonts/liberation v0.6.0/go.mod h1:J15VAa+lyxdcI/Je7lDDDl6QOhLk9feNBnnwXqEHXOk= +codeberg.org/go-latex/latex v0.3.0 h1:LKTaDHFbEC2PH1sh0sYv6PZ1pzs/g2aoeV1HItWj/bg= +codeberg.org/go-latex/latex v0.3.0/go.mod h1:8ETijTpK2bFtwRAXLXe1RZJrYxnc5pibibZfQBj+Lk4= +codeberg.org/go-pdf/fpdf v0.12.0 h1:g8E/1VqGqB2lZUUaqQrrTnA0IEJLPTTX1DZ0qS/ZmhU= +codeberg.org/go-pdf/fpdf v0.12.0/go.mod h1:WJNJ2bvCj81rZBdhOf7lKOGoSl+OKMXcIcXqDcP8r5Y= git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo= git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE= -git.sr.ht/~sbinet/gg v0.6.0 h1:RIzgkizAk+9r7uPzf/VfbJHBMKUr0F5hRFxTUGMnt38= -git.sr.ht/~sbinet/gg v0.6.0/go.mod h1:uucygbfC9wVPQIfrmwM2et0imr8L7KQWywX0xpFMm94= +git.sr.ht/~sbinet/gg v0.8.0 h1:PjQ4AgUWRz7Dy6PVBKMLLg96eRCos1U+H6F3FJuKWHo= +git.sr.ht/~sbinet/gg v0.8.0/go.mod h1:XhlGCvSXts+BaZ1XMZLxLSFUDvwsJ/2El5F6XzPep6o= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= -github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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.40.0 h1:Tw4GyDXMo+daZN1znreBRC3VayR1aLFUyUEOLUdW1a8= golang.org/x/image v0.40.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -54,10 +50,10 @@ golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.15.1 h1:FNy7N6OUZVUaWG9pTiD+jlhdQ3lMP+/LcTpJ6+a8sQ0= -gonum.org/v1/gonum v0.15.1/go.mod h1:eZTZuRFrzu5pcyjN5wJhcIhnUdNijYxX1T2IcrOGY0o= -gonum.org/v1/plot v0.15.1 h1:kASfUwe3GV6V1aLae8Ljhd+CcIG8XjeAC2CFGUwz0U4= -gonum.org/v1/plot v0.15.1/go.mod h1:ionBLCeO4VrVHg93/wpkRqj/fkOckrb9p/4ePN7yRXE= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= +gonum.org/v1/plot v0.17.0 h1:d0DwPVBe9jnEGqQBoZGl/P2M9WciJbG2CnV59C9QBT4= +gonum.org/v1/plot v0.17.0/go.mod h1:ipt2GUN1oqzr2O7wCjLDtw1ShfIYYNBp4o0O1Ez5B3Y= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/linsolve/iterative_test.go b/linsolve/iterative_test.go index 4456a43..601aa92 100644 --- a/linsolve/iterative_test.go +++ b/linsolve/iterative_test.go @@ -6,16 +6,15 @@ package linsolve import ( "math" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/mat" ) func TestDefaultMethodDefaultSettings(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -44,7 +43,7 @@ func TestDefaultMethodDefaultSettings(t *testing.T) { } func TestCG(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) for _, tc := range testCases { @@ -54,7 +53,7 @@ func TestCG(t *testing.T) { } func TestCGDefaultSettings(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) for _, tc := range testCases { @@ -63,7 +62,7 @@ func TestCGDefaultSettings(t *testing.T) { } func TestBiCG(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -91,7 +90,7 @@ func TestBiCG(t *testing.T) { } func TestBiCGDefaultSettings(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -118,7 +117,7 @@ func TestBiCGDefaultSettings(t *testing.T) { } func TestBiCGStab(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -139,7 +138,7 @@ func TestBiCGStab(t *testing.T) { } func TestBiCGStabDefaultSettings(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -159,7 +158,7 @@ func TestBiCGStabDefaultSettings(t *testing.T) { } func TestGMRES(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, @@ -189,7 +188,7 @@ func TestGMRES(t *testing.T) { } func TestGMRESDefaultSettings(t *testing.T) { - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) testCases := spdTestCases(rnd) testCases = append(testCases, diff --git a/linsolve/linsolve_test.go b/linsolve/linsolve_test.go index 3a874cb..321a75f 100644 --- a/linsolve/linsolve_test.go +++ b/linsolve/linsolve_test.go @@ -7,8 +7,7 @@ package linsolve import ( "fmt" "math" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/exp/linsolve/internal/triplet" "gonum.org/v1/gonum/lapack/testlapack" @@ -331,7 +330,7 @@ func newGreenbaum54(n1, n2 int, rnd *rand.Rand) testCase { // Generate n2 real eigenvalues. for i := 2 * n1; i < n; i++ { r := 9*rnd.Float64() + 1 - if rnd.Intn(2) == 0 { + if rnd.IntN(2) == 0 { r *= -1 } d[i*3+1] = r diff --git a/linsolve/pde_example_test.go b/linsolve/pde_example_test.go index 63764f5..83f0c38 100644 --- a/linsolve/pde_example_test.go +++ b/linsolve/pde_example_test.go @@ -7,8 +7,7 @@ package linsolve_test import ( "fmt" "log" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/exp/linsolve" "gonum.org/v1/gonum/mat" @@ -230,7 +229,7 @@ func ExampleIterative_evolutionPDE() { tau = 0.1 * L / nx xi = 6.0 * L / nx ) - rnd := rand.New(rand.NewSource(1)) + rnd := rand.New(rand.NewPCG(1, 1)) ac := AllenCahnFD{ Xi: xi, InitCond: func(x float64) float64 { diff --git a/plotter/rings/axis_test.go b/plotter/rings/axis_test.go index 42c1be9..acb593e 100644 --- a/plotter/rings/axis_test.go +++ b/plotter/rings/axis_test.go @@ -7,10 +7,9 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/font" "gonum.org/v1/plot/font/liberation" @@ -19,8 +18,8 @@ import ( ) func TestScoresAxis(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) diff --git a/plotter/rings/bezier.go b/plotter/rings/bezier.go index c7038d7..249142c 100644 --- a/plotter/rings/bezier.go +++ b/plotter/rings/bezier.go @@ -6,8 +6,7 @@ package rings import ( "math" - - "golang.org/x/exp/rand" + "math/rand/v2" "gonum.org/v1/plot/vg" ) @@ -72,6 +71,17 @@ type Bezier struct { // If nil, these values are not used. Crest *FactorDist Purity *FactorDist + + // Src is a source of random numbers. + // If nil, the global one is used. + Src rand.Source +} + +func (b *Bezier) f64() float64 { + if b.Src == nil { + return rand.Float64() + } + return rand.New(b.Src).Float64() } // ControlPoints returns a set of Bézier curve control points defining the path between the points defined @@ -85,7 +95,7 @@ func (b *Bezier) ControlPoints(a [2]Angle, rad [2]vg.Length) []vg.Point { var radius = b.Radius if b.Purity != nil { bisectRadius := vg.Length(math.Hypot(float64(p[0].X+p[1].X)/2, float64(p[0].Y+p[1].Y)/2)) - radius.Length += vg.Length(b.Purity.Perturb(rand.Float64())-1) * (radius.Length - bisectRadius) + radius.Length += vg.Length(b.Purity.Perturb(b.f64())-1) * (radius.Length - bisectRadius) } var bisect Angle @@ -94,11 +104,11 @@ func (b *Bezier) ControlPoints(a [2]Angle, rad [2]vg.Length) []vg.Point { } else { bisect = (a[1] + a[0]) / 2 } - mid := Rectangular(bisect, radius.Perturb(rand.Float64())) + mid := Rectangular(bisect, radius.Perturb(b.f64())) if b.Crest != nil { points := []vg.Point{0: p[0], 2: mid, 4: p[1]} - c := b.Crest.Perturb(rand.Float64()) + c := b.Crest.Perturb(b.f64()) for i, r := range rad { points[2*i+1] = Rectangular(a[i], r-(r-radius.Length)*vg.Length(c)) diff --git a/plotter/rings/blocks_test.go b/plotter/rings/blocks_test.go index a4d5c89..c343a8a 100644 --- a/plotter/rings/blocks_test.go +++ b/plotter/rings/blocks_test.go @@ -7,10 +7,9 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/font" "gonum.org/v1/plot/font/liberation" @@ -21,8 +20,8 @@ import ( func TestBlocks(t *testing.T) { p := plot.New() - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -39,8 +38,8 @@ func TestBlocks(t *testing.T) { } func TestBlocksScale(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) diff --git a/plotter/rings/example.go b/plotter/rings/example.go index 6e19a02..5c36883 100644 --- a/plotter/rings/example.go +++ b/plotter/rings/example.go @@ -11,10 +11,9 @@ import ( "flag" "fmt" "image/color" + "math/rand/v2" "os" - "golang.org/x/exp/rand" - "gonum.org/v1/exp/plotter/rings" "gonum.org/v1/plot" "gonum.org/v1/plot/font" @@ -43,7 +42,7 @@ func init() { func floatPtr(f float64) *float64 { return &f } func main() { - rand.Seed(0) + rnd := rand.New(rand.NewPCG(1, 1)) p := plot.New() sty := plotter.DefaultLineStyle @@ -55,7 +54,7 @@ func main() { g := byte(0) for i := vg.Length(0); i < 3; i++ { - bs, err := rings.NewGappedBlocks(randomFeatures(rand.Intn(10), 1000, 1000000, false, sty), rings.Arc{0, rings.Complete * rings.Clockwise}, 50+i*8, 55+i*8, 0.005) + bs, err := rings.NewGappedBlocks(randomFeatures(rnd, rnd.IntN(10), 1000, 1000000, false, sty), rings.Arc{0, rings.Complete * rings.Clockwise}, 50+i*8, 55+i*8, 0.005) if err != nil { panic(err) } @@ -64,7 +63,7 @@ func main() { p.Add(bs) } - bs, err := rings.NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, sty), rings.Arc{0, rings.Complete * rings.Clockwise}, 80, 100, 0.01) + bs, err := rings.NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, sty), rings.Arc{0, rings.Complete * rings.Clockwise}, 80, 100, 0.01) if err != nil { panic(err) } @@ -86,7 +85,7 @@ func main() { lb.TextStyle = draw.TextStyle{Color: color.Gray16{0}, Font: fnt.Font} p.Add(lb) - m := randomFeatures(400, bs.Set[1].Start(), bs.Set[1].End(), true, sty) + m := randomFeatures(rnd, 400, bs.Set[1].Start(), bs.Set[1].End(), true, sty) for _, mf := range m { mf.(*fs).parent = bs.Set[1] } @@ -221,15 +220,15 @@ func lengthOf(f rings.Feature) float64 { return f.End() - f.Start() } -func randomFeatures(n int, min, max float64, single bool, sty draw.LineStyle) []rings.Feature { +func randomFeatures(rnd *rand.Rand, n int, min, max float64, single bool, sty draw.LineStyle) []rings.Feature { data := make([]rings.Feature, n) for i := range data { - // Intn is used here to avoid drastic random + // IntN is used here to avoid drastic random // sequence changes at this stage. - start := float64(rand.Intn(int(max-min))) + min + start := float64(rnd.IntN(int(max-min))) + min var end float64 if !single { - end = float64(rand.Intn(int(max - start))) + end = float64(rnd.IntN(int(max - start))) } data[i] = &fs{ start: start, diff --git a/plotter/rings/labels_test.go b/plotter/rings/labels_test.go index 2964c9e..1c69fd6 100644 --- a/plotter/rings/labels_test.go +++ b/plotter/rings/labels_test.go @@ -7,10 +7,9 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/font" "gonum.org/v1/plot/font/liberation" @@ -19,8 +18,8 @@ import ( ) func TestLabelsBlocks(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -136,8 +135,8 @@ func TestLabelsArcs(t *testing.T) { func TestLabelSpokes(t *testing.T) { p := plot.New() - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -145,7 +144,7 @@ func TestLabelSpokes(t *testing.T) { t.Fatalf("unexpected error for NewGappedBlocks: %v", err) } - m := randomFeatures(10, b.Set[1].Start(), b.Set[1].End(), true, plotter.DefaultLineStyle) + m := randomFeatures(rnd, 10, b.Set[1].Start(), b.Set[1].End(), true, plotter.DefaultLineStyle) for _, mf := range m { mf.(*fs).parent = b.Set[1] } diff --git a/plotter/rings/links_test.go b/plotter/rings/links_test.go index b209a99..e560a87 100644 --- a/plotter/rings/links_test.go +++ b/plotter/rings/links_test.go @@ -6,10 +6,9 @@ package rings import ( "fmt" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" @@ -18,8 +17,8 @@ import ( func TestLinks(t *testing.T) { const marks = 16 - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -36,6 +35,7 @@ func TestLinks(t *testing.T) { bezier: &Bezier{Segments: 5, Radius: LengthDist{Length: 2 * 70 / 3, Min: floatPtr(0.95), Max: floatPtr(1.05)}, Crest: &FactorDist{Factor: 2, Min: floatPtr(0.7), Max: floatPtr(1.4)}, + Src: rand.NewPCG(1, 1), }, }, { @@ -43,15 +43,16 @@ func TestLinks(t *testing.T) { bezier: &Bezier{Segments: 5, Radius: LengthDist{Length: 2 * 70 / 3, Min: floatPtr(0.95), Max: floatPtr(1.05)}, Crest: &FactorDist{Factor: 2, Min: floatPtr(0.7), Max: floatPtr(1.4)}, + Src: rand.NewPCG(2, 2), }, }, } { t.Run(fmt.Sprintf("links-%d", i), func(t *testing.T) { p := plot.New() var m [2][]Feature - rand.Seed(2) + rnd := rand.New(rand.NewPCG(2, 2)) for j := range m { - m[j] = randomFeatures(marks/2, test.ends[j].Start(), test.ends[j].End(), true, plotter.DefaultLineStyle) + m[j] = randomFeatures(rnd, marks/2, test.ends[j].Start(), test.ends[j].End(), true, plotter.DefaultLineStyle) } mp := make([]Pair, marks/2) for j := range mp { diff --git a/plotter/rings/ribbons_test.go b/plotter/rings/ribbons_test.go index d5edb05..bec287e 100644 --- a/plotter/rings/ribbons_test.go +++ b/plotter/rings/ribbons_test.go @@ -7,18 +7,17 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" ) func TestRibbons(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) diff --git a/plotter/rings/rings_test.go b/plotter/rings/rings_test.go index 2eb888b..2a1a0c0 100644 --- a/plotter/rings/rings_test.go +++ b/plotter/rings/rings_test.go @@ -7,11 +7,10 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "path/filepath" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/cmpimg" "gonum.org/v1/plot/vg" @@ -55,15 +54,15 @@ func (p fp) LineStyle() draw.LineStyle { return p.sty } -func randomFeatures(n int, min, max float64, single bool, sty draw.LineStyle) []Feature { +func randomFeatures(rnd *rand.Rand, n int, min, max float64, single bool, sty draw.LineStyle) []Feature { data := make([]Feature, n) for i := range data { - // Intn is used here to avoid drastic random + // IntN is used here to avoid drastic random // sequence changes at this stage. - start := float64(rand.Intn(int(max-min))) + min + start := float64(rnd.IntN(int(max-min))) + min var end float64 if !single { - end = float64(rand.Intn(int(max - start))) + end = float64(rnd.IntN(int(max - start))) } data[i] = &fs{ start: start, diff --git a/plotter/rings/sail_test.go b/plotter/rings/sail_test.go index 483c751..12b20dd 100644 --- a/plotter/rings/sail_test.go +++ b/plotter/rings/sail_test.go @@ -7,17 +7,16 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" ) func TestSail(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) diff --git a/plotter/rings/scores_test.go b/plotter/rings/scores_test.go index 9827777..c900e78 100644 --- a/plotter/rings/scores_test.go +++ b/plotter/rings/scores_test.go @@ -7,10 +7,9 @@ package rings import ( "fmt" "image/color" + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/palette" "gonum.org/v1/plot/plotter" @@ -18,8 +17,8 @@ import ( ) func TestScores(t *testing.T) { - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -37,7 +36,7 @@ func TestScores(t *testing.T) { renderer: &Heat{Palette: palette.Radial(10, palette.Cyan, palette.Magenta, 1).Colors()}, }, { - scores: makeScorers(b.Set[1].(*fs), 10, 5, func(_, _ int) float64 { return rand.NormFloat64() }), + scores: makeScorers(b.Set[1].(*fs), 10, 5, func(_, _ int) float64 { return rnd.NormFloat64() }), renderer: &Heat{Palette: palette.Radial(10, palette.Cyan, palette.Magenta, 1).Colors()}, }, { @@ -266,7 +265,7 @@ func TestScores(t *testing.T) { }, }, { - scores: makeScorers(b.Set[1].(*fs), 10, 2, func(_, _ int) float64 { return rand.NormFloat64() }), + scores: makeScorers(b.Set[1].(*fs), 10, 2, func(_, _ int) float64 { return rnd.NormFloat64() }), renderer: &Trace{ LineStyles: func() []draw.LineStyle { sty := []draw.LineStyle{plotter.DefaultLineStyle, plotter.DefaultLineStyle} @@ -277,7 +276,7 @@ func TestScores(t *testing.T) { }, }, { - scores: makeScorers(b.Set[1].(*fs), 10, 2, func(_, _ int) float64 { return rand.NormFloat64() }), + scores: makeScorers(b.Set[1].(*fs), 10, 2, func(_, _ int) float64 { return rnd.NormFloat64() }), renderer: &Trace{ LineStyles: func() []draw.LineStyle { sty := []draw.LineStyle{plotter.DefaultLineStyle, plotter.DefaultLineStyle} diff --git a/plotter/rings/spokes_test.go b/plotter/rings/spokes_test.go index 0f6f306..94b41a8 100644 --- a/plotter/rings/spokes_test.go +++ b/plotter/rings/spokes_test.go @@ -5,18 +5,17 @@ package rings import ( + "math/rand/v2" "testing" - "golang.org/x/exp/rand" - "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" ) func TestSpokes(t *testing.T) { p := plot.New() - rand.Seed(1) - b, err := NewGappedBlocks(randomFeatures(3, 100000, 1000000, false, plotter.DefaultLineStyle), + rnd := rand.New(rand.NewPCG(1, 1)) + b, err := NewGappedBlocks(randomFeatures(rnd, 3, 100000, 1000000, false, plotter.DefaultLineStyle), Arc{0, Complete * Clockwise}, 80, 100, 0.01, ) @@ -24,7 +23,7 @@ func TestSpokes(t *testing.T) { t.Fatalf("unexpected error for NewGappedBlocks: %v", err) } - m := randomFeatures(10, b.Set[1].Start(), b.Set[1].End(), true, plotter.DefaultLineStyle) + m := randomFeatures(rnd, 10, b.Set[1].Start(), b.Set[1].End(), true, plotter.DefaultLineStyle) for _, mf := range m { mf.(*fs).parent = b.Set[1] } diff --git a/plotter/rings/testdata/TestBlocksScale/scale-0_golden.png b/plotter/rings/testdata/TestBlocksScale/scale-0_golden.png index ac7f904..a045f7f 100644 Binary files a/plotter/rings/testdata/TestBlocksScale/scale-0_golden.png and b/plotter/rings/testdata/TestBlocksScale/scale-0_golden.png differ diff --git a/plotter/rings/testdata/TestBlocksScale/scale-1_golden.png b/plotter/rings/testdata/TestBlocksScale/scale-1_golden.png index 5a3c2a6..fd5ac59 100644 Binary files a/plotter/rings/testdata/TestBlocksScale/scale-1_golden.png and b/plotter/rings/testdata/TestBlocksScale/scale-1_golden.png differ diff --git a/plotter/rings/testdata/TestBlocks_golden.png b/plotter/rings/testdata/TestBlocks_golden.png index 4fba470..15dc984 100644 Binary files a/plotter/rings/testdata/TestBlocks_golden.png and b/plotter/rings/testdata/TestBlocks_golden.png differ diff --git a/plotter/rings/testdata/TestLabelSpokes_golden.png b/plotter/rings/testdata/TestLabelSpokes_golden.png index 9ee4e3d..435135b 100644 Binary files a/plotter/rings/testdata/TestLabelSpokes_golden.png and b/plotter/rings/testdata/TestLabelSpokes_golden.png differ diff --git a/plotter/rings/testdata/TestLabelsBlocks/labels-0_golden.png b/plotter/rings/testdata/TestLabelsBlocks/labels-0_golden.png index 1e8d4ef..a715370 100644 Binary files a/plotter/rings/testdata/TestLabelsBlocks/labels-0_golden.png and b/plotter/rings/testdata/TestLabelsBlocks/labels-0_golden.png differ diff --git a/plotter/rings/testdata/TestLabelsBlocks/labels-1_golden.png b/plotter/rings/testdata/TestLabelsBlocks/labels-1_golden.png index 344aa61..a3fe403 100644 Binary files a/plotter/rings/testdata/TestLabelsBlocks/labels-1_golden.png and b/plotter/rings/testdata/TestLabelsBlocks/labels-1_golden.png differ diff --git a/plotter/rings/testdata/TestLabelsBlocks/labels-2_golden.png b/plotter/rings/testdata/TestLabelsBlocks/labels-2_golden.png index 117197e..3719a9c 100644 Binary files a/plotter/rings/testdata/TestLabelsBlocks/labels-2_golden.png and b/plotter/rings/testdata/TestLabelsBlocks/labels-2_golden.png differ diff --git a/plotter/rings/testdata/TestLabelsBlocks/labels-3_golden.png b/plotter/rings/testdata/TestLabelsBlocks/labels-3_golden.png index de865cb..6512bb1 100644 Binary files a/plotter/rings/testdata/TestLabelsBlocks/labels-3_golden.png and b/plotter/rings/testdata/TestLabelsBlocks/labels-3_golden.png differ diff --git a/plotter/rings/testdata/TestLabelsBlocks/labels-4_golden.png b/plotter/rings/testdata/TestLabelsBlocks/labels-4_golden.png index fc8b862..560adc5 100644 Binary files a/plotter/rings/testdata/TestLabelsBlocks/labels-4_golden.png and b/plotter/rings/testdata/TestLabelsBlocks/labels-4_golden.png differ diff --git a/plotter/rings/testdata/TestLinks/links-0_golden.png b/plotter/rings/testdata/TestLinks/links-0_golden.png index 9feb58d..f1bff02 100644 Binary files a/plotter/rings/testdata/TestLinks/links-0_golden.png and b/plotter/rings/testdata/TestLinks/links-0_golden.png differ diff --git a/plotter/rings/testdata/TestLinks/links-1_golden.png b/plotter/rings/testdata/TestLinks/links-1_golden.png index e867ba4..02f1708 100644 Binary files a/plotter/rings/testdata/TestLinks/links-1_golden.png and b/plotter/rings/testdata/TestLinks/links-1_golden.png differ diff --git a/plotter/rings/testdata/TestRibbons/ribbons-0_golden.png b/plotter/rings/testdata/TestRibbons/ribbons-0_golden.png index c80eb4f..146d185 100644 Binary files a/plotter/rings/testdata/TestRibbons/ribbons-0_golden.png and b/plotter/rings/testdata/TestRibbons/ribbons-0_golden.png differ diff --git a/plotter/rings/testdata/TestRibbons/ribbons-1_golden.png b/plotter/rings/testdata/TestRibbons/ribbons-1_golden.png index a4ed376..57adfcb 100644 Binary files a/plotter/rings/testdata/TestRibbons/ribbons-1_golden.png and b/plotter/rings/testdata/TestRibbons/ribbons-1_golden.png differ diff --git a/plotter/rings/testdata/TestRibbons/ribbons-2_golden.png b/plotter/rings/testdata/TestRibbons/ribbons-2_golden.png index ed036a7..bcfb9b0 100644 Binary files a/plotter/rings/testdata/TestRibbons/ribbons-2_golden.png and b/plotter/rings/testdata/TestRibbons/ribbons-2_golden.png differ diff --git a/plotter/rings/testdata/TestRibbons/ribbons-3_golden.png b/plotter/rings/testdata/TestRibbons/ribbons-3_golden.png index 27b6b15..d06a73b 100644 Binary files a/plotter/rings/testdata/TestRibbons/ribbons-3_golden.png and b/plotter/rings/testdata/TestRibbons/ribbons-3_golden.png differ diff --git a/plotter/rings/testdata/TestSail/sail-0_golden.png b/plotter/rings/testdata/TestSail/sail-0_golden.png index 1b23719..2058587 100644 Binary files a/plotter/rings/testdata/TestSail/sail-0_golden.png and b/plotter/rings/testdata/TestSail/sail-0_golden.png differ diff --git a/plotter/rings/testdata/TestSail/sail-1_golden.png b/plotter/rings/testdata/TestSail/sail-1_golden.png index bc23ff8..f3d71b6 100644 Binary files a/plotter/rings/testdata/TestSail/sail-1_golden.png and b/plotter/rings/testdata/TestSail/sail-1_golden.png differ diff --git a/plotter/rings/testdata/TestSail/sail-2_golden.png b/plotter/rings/testdata/TestSail/sail-2_golden.png index bca4ed3..ffaa3aa 100644 Binary files a/plotter/rings/testdata/TestSail/sail-2_golden.png and b/plotter/rings/testdata/TestSail/sail-2_golden.png differ diff --git a/plotter/rings/testdata/TestSail/sail-3_golden.png b/plotter/rings/testdata/TestSail/sail-3_golden.png index 42ca96a..450e429 100644 Binary files a/plotter/rings/testdata/TestSail/sail-3_golden.png and b/plotter/rings/testdata/TestSail/sail-3_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-0_golden.png b/plotter/rings/testdata/TestScores/scores-0_golden.png index af9a3f7..0e8fc88 100644 Binary files a/plotter/rings/testdata/TestScores/scores-0_golden.png and b/plotter/rings/testdata/TestScores/scores-0_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-10_golden.png b/plotter/rings/testdata/TestScores/scores-10_golden.png index fb6c389..3225992 100644 Binary files a/plotter/rings/testdata/TestScores/scores-10_golden.png and b/plotter/rings/testdata/TestScores/scores-10_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-11_golden.png b/plotter/rings/testdata/TestScores/scores-11_golden.png index f8d832c..c6d1f94 100644 Binary files a/plotter/rings/testdata/TestScores/scores-11_golden.png and b/plotter/rings/testdata/TestScores/scores-11_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-1_golden.png b/plotter/rings/testdata/TestScores/scores-1_golden.png index 4338347..ca69d82 100644 Binary files a/plotter/rings/testdata/TestScores/scores-1_golden.png and b/plotter/rings/testdata/TestScores/scores-1_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-2_golden.png b/plotter/rings/testdata/TestScores/scores-2_golden.png index 1d84d82..8f54219 100644 Binary files a/plotter/rings/testdata/TestScores/scores-2_golden.png and b/plotter/rings/testdata/TestScores/scores-2_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-3_golden.png b/plotter/rings/testdata/TestScores/scores-3_golden.png index 3e53f82..53e2ee8 100644 Binary files a/plotter/rings/testdata/TestScores/scores-3_golden.png and b/plotter/rings/testdata/TestScores/scores-3_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-4_golden.png b/plotter/rings/testdata/TestScores/scores-4_golden.png index 7f51d7a..bb8504e 100644 Binary files a/plotter/rings/testdata/TestScores/scores-4_golden.png and b/plotter/rings/testdata/TestScores/scores-4_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-5_golden.png b/plotter/rings/testdata/TestScores/scores-5_golden.png index af63de5..cf0e093 100644 Binary files a/plotter/rings/testdata/TestScores/scores-5_golden.png and b/plotter/rings/testdata/TestScores/scores-5_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-6_golden.png b/plotter/rings/testdata/TestScores/scores-6_golden.png index 3dc42ca..feca9c3 100644 Binary files a/plotter/rings/testdata/TestScores/scores-6_golden.png and b/plotter/rings/testdata/TestScores/scores-6_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-7_golden.png b/plotter/rings/testdata/TestScores/scores-7_golden.png index 8d0e40b..77593d1 100644 Binary files a/plotter/rings/testdata/TestScores/scores-7_golden.png and b/plotter/rings/testdata/TestScores/scores-7_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-8_golden.png b/plotter/rings/testdata/TestScores/scores-8_golden.png index 613e75e..d94f8d1 100644 Binary files a/plotter/rings/testdata/TestScores/scores-8_golden.png and b/plotter/rings/testdata/TestScores/scores-8_golden.png differ diff --git a/plotter/rings/testdata/TestScores/scores-9_golden.png b/plotter/rings/testdata/TestScores/scores-9_golden.png index 0a0f239..ee7c36f 100644 Binary files a/plotter/rings/testdata/TestScores/scores-9_golden.png and b/plotter/rings/testdata/TestScores/scores-9_golden.png differ diff --git a/plotter/rings/testdata/TestScoresAxis/axis-0_golden.png b/plotter/rings/testdata/TestScoresAxis/axis-0_golden.png index d1f2f80..32bda21 100644 Binary files a/plotter/rings/testdata/TestScoresAxis/axis-0_golden.png and b/plotter/rings/testdata/TestScoresAxis/axis-0_golden.png differ diff --git a/plotter/rings/testdata/TestSpokes_golden.png b/plotter/rings/testdata/TestSpokes_golden.png index 62a5c8a..345c197 100644 Binary files a/plotter/rings/testdata/TestSpokes_golden.png and b/plotter/rings/testdata/TestSpokes_golden.png differ