Skip to content
Draft
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.23.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.16.0
gonum.org/v1/plot v0.16.0
)

require (
Expand Down
21 changes: 10 additions & 11 deletions linsolve/iterative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions linsolve/linsolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions linsolve/pde_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions plotter/rings/axis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
)
Expand Down
11 changes: 5 additions & 6 deletions plotter/rings/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
)
Expand All @@ -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,
)
Expand Down
13 changes: 6 additions & 7 deletions plotter/rings/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
)
Expand Down Expand Up @@ -136,16 +135,16 @@ 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,
)
if err != nil {
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]
}
Expand Down
11 changes: 5 additions & 6 deletions plotter/rings/links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
)
Expand Down Expand Up @@ -49,9 +48,9 @@ func TestLinks(t *testing.T) {
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 {
Expand Down
7 changes: 3 additions & 4 deletions plotter/rings/ribbons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
11 changes: 5 additions & 6 deletions plotter/rings/rings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions plotter/rings/sail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Loading
Loading