Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 7dc9fd2

Browse files
committed
all: use go tool embedmd
Signed-off-by: Sebastien Binet <[email protected]>
1 parent 89bd3d3 commit 7dc9fd2

File tree

9 files changed

+49
-52
lines changed

9 files changed

+49
-52
lines changed

fit/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleH1D_gaussian() {
1717
mean = 2.0
1818
sigma = 4.0
1919
// Values from gonum/optimize:
20-
want = []float64{447.0483517081991, 2.02127773281178, 3.9965893891862687}
20+
want = []float64{450.56454241860934, 2.0146898541006277, 3.9613086671267466}
2121
// Values from ROOT:
2222
// want = []float64{4.53720e+02, 1.93218e+00, 3.93188e+00}
2323
)
@@ -28,13 +28,13 @@ func ExampleH1D_gaussian() {
2828
dist := distuv.Normal{
2929
Mu: mean,
3030
Sigma: sigma,
31-
Src: rand.New(rand.NewSource(0)),
31+
Src: rand.New(rand.NewPCG(0, 0)),
3232
}
3333

3434
// Draw some random values from the standard
3535
// normal distribution.
3636
hist := hbook.NewH1D(100, -20, +25)
37-
for i := 0; i < npoints; i++ {
37+
for range npoints {
3838
v := dist.Rand()
3939
hist.Fill(v, 1)
4040
}

fit/fit.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
"gonum.org/v1/gonum/mat"
1111
)
1212

13-
//go:generate go get github.com/campoy/embedmd
14-
//go:generate embedmd -w README.md
13+
//go:generate go tool github.com/campoy/embedmd -w README.md
1514

1615
// Func1D describes a 1D function to fit some data.
1716
type Func1D struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
codeberg.org/sbinet/npyio v0.11.0
1111
git.sr.ht/~sbinet/epok v0.5.0
1212
git.sr.ht/~sbinet/go-arrow v0.3.0
13-
github.com/campoy/embedmd v1.0.0
1413
github.com/google/go-cmp v0.7.0
1514
github.com/hashicorp/go-uuid v1.0.3
1615
github.com/jcmturner/gokrb5/v8 v8.4.4
@@ -37,6 +36,7 @@ require (
3736
codeberg.org/go-pdf/fpdf v0.11.1 // indirect
3837
git.sr.ht/~sbinet/gg v0.6.0 // indirect
3938
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
39+
github.com/campoy/embedmd v1.0.0 // indirect
4040
github.com/edsrzf/mmap-go v1.2.0 // indirect
4141
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
4242
github.com/google/flatbuffers v25.2.10+incompatible // indirect

hbook/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ func ExampleH1D() {
3333
dist := distuv.Normal{
3434
Mu: 0,
3535
Sigma: 1,
36-
Src: rand.New(rand.NewSource(0)),
36+
Src: rand.New(rand.NewPCG(0, 0)),
3737
}
3838

3939
// Draw some random values from the standard
4040
// normal distribution.
4141
h := hbook.NewH1D(20, -4, +4)
42-
for i := 0; i < npoints; i++ {
42+
for range npoints {
4343
v := dist.Rand()
4444
h.Fill(v, 1)
4545
}
4646
// fill h with a slice of values and their weights
4747
h.FillN([]float64{1, 2, 3}, []float64{1, 1, 1})
4848
h.FillN([]float64{1, 2, 3}, nil) // all weights are 1.
4949

50-
fmt.Printf("mean: %v\n", h.XMean())
51-
fmt.Printf("rms: %v\n", h.XRMS())
52-
fmt.Printf("std-dev: %v\n", h.XStdDev())
53-
fmt.Printf("std-err: %v\n", h.XStdErr())
50+
fmt.Printf("mean: %.12f\n", h.XMean())
51+
fmt.Printf("rms: %.12f\n", h.XRMS())
52+
fmt.Printf("std-dev: %.12f\n", h.XStdDev())
53+
fmt.Printf("std-err: %.12f\n", h.XStdErr())
5454

5555
// Output:
56-
// mean: 0.005589967511734562
57-
// rms: 1.0062596231244403
58-
// std-dev: 1.0062943821322063
59-
// std-err: 0.010059926295994191
56+
// mean: 0.002104228518
57+
// rms: 1.000617135827
58+
// std-dev: 1.000664927794
59+
// std-err: 0.010003648633
6060
}
6161
```
6262

@@ -86,7 +86,7 @@ func ExampleAddH1D() {
8686

8787
hsum := hbook.AddH1D(h1, h2)
8888
fmt.Printf("Under: %.1f +/- %.1f\n", hsum.Binning.Outflows[0].SumW(), math.Sqrt(hsum.Binning.Outflows[0].SumW2()))
89-
for i := 0; i < hsum.Len(); i++ {
89+
for i := range hsum.Len() {
9090
fmt.Printf("Bin %v: %.1f +/- %.1f\n", i, hsum.Binning.Bins[i].SumW(), math.Sqrt(hsum.Binning.Bins[i].SumW2()))
9191
}
9292
fmt.Printf("Over : %.1f +/- %.1f\n", hsum.Binning.Outflows[1].SumW(), math.Sqrt(hsum.Binning.Outflows[1].SumW2()))
@@ -128,7 +128,7 @@ func ExampleAddScaledH1D() {
128128

129129
hsum := hbook.AddScaledH1D(h1, 10, h2)
130130
fmt.Printf("Under: %.1f +/- %.1f\n", hsum.Binning.Outflows[0].SumW(), math.Sqrt(hsum.Binning.Outflows[0].SumW2()))
131-
for i := 0; i < hsum.Len(); i++ {
131+
for i := range hsum.Len() {
132132
fmt.Printf("Bin %v: %.1f +/- %.1f\n", i, hsum.Binning.Bins[i].SumW(), math.Sqrt(hsum.Binning.Bins[i].SumW2()))
133133
}
134134
fmt.Printf("Over : %.1f +/- %.1f\n", hsum.Binning.Outflows[1].SumW(), math.Sqrt(hsum.Binning.Outflows[1].SumW2()))
@@ -201,7 +201,7 @@ func ExampleH2D() {
201201
dist, ok := distmv.NewNormal(
202202
[]float64{0, 1},
203203
mat.NewSymDense(2, []float64{4, 0, 0, 2}),
204-
rand.New(rand.NewSource(1234)),
204+
rand.New(rand.NewPCG(1234, 1234)),
205205
)
206206
if !ok {
207207
log.Fatalf("error creating distmv.Normal")
@@ -210,7 +210,7 @@ func ExampleH2D() {
210210
v := make([]float64, 2)
211211
// Draw some random values from the standard
212212
// normal distribution.
213-
for i := 0; i < npoints; i++ {
213+
for range npoints {
214214
v = dist.Rand(v)
215215
h.Fill(v[0], v[1], 1)
216216
}

hbook/hbook.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"math"
99
)
1010

11-
//go:generate go get github.com/campoy/embedmd
12-
//go:generate embedmd -w README.md
11+
//go:generate go tool github.com/campoy/embedmd -w README.md
1312

1413
//go:generate -command brio-gen go run go-hep.org/x/hep/brio/cmd/brio-gen
1514
//go:generate brio-gen -p go-hep.org/x/hep/hbook -t Dist0D,Dist1D,Dist2D -o dist_brio.go

hplot/README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func ExampleH1D() {
3434
dist := distuv.Normal{
3535
Mu: 0,
3636
Sigma: 1,
37-
Src: rand.New(rand.NewSource(0)),
37+
Src: rand.New(rand.NewPCG(0, 0)),
3838
}
3939

4040
// Draw some random values from the standard
4141
// normal distribution.
4242
hist := hbook.NewH1D(20, -4, +4)
43-
for i := 0; i < npoints; i++ {
43+
for range npoints {
4444
v := dist.Rand()
4545
hist.Fill(v, 1)
4646
}
@@ -93,13 +93,13 @@ func ExampleH1D_withYErrBars() {
9393
dist := distuv.Normal{
9494
Mu: 0,
9595
Sigma: 1,
96-
Src: rand.New(rand.NewSource(0)),
96+
Src: rand.New(rand.NewPCG(0, 0)),
9797
}
9898

9999
// Draw some random values from the standard
100100
// normal distribution.
101101
hist := hbook.NewH1D(20, -4, +4)
102-
for i := 0; i < npoints; i++ {
102+
for range npoints {
103103
v := dist.Rand()
104104
hist.Fill(v, 1)
105105
}
@@ -155,13 +155,13 @@ func ExampleH1D_withYErrBarsAndData() {
155155
dist := distuv.Normal{
156156
Mu: 0,
157157
Sigma: 1,
158-
Src: rand.New(rand.NewSource(0)),
158+
Src: rand.New(rand.NewPCG(0, 0)),
159159
}
160160

161161
// Draw some random values from the standard
162162
// normal distribution.
163163
hist := hbook.NewH1D(20, -4, +4)
164-
for i := 0; i < npoints; i++ {
164+
for range npoints {
165165
v := dist.Rand()
166166
hist.Fill(v, 1)
167167
}
@@ -229,13 +229,13 @@ func ExampleH1D_withYErrBars_withBand() {
229229
dist := distuv.Normal{
230230
Mu: 0,
231231
Sigma: 1,
232-
Src: rand.New(rand.NewSource(0)),
232+
Src: rand.New(rand.NewPCG(0, 0)),
233233
}
234234

235235
// Draw some random values from the standard
236236
// normal distribution.
237237
hist := hbook.NewH1D(20, -4, +4)
238-
for i := 0; i < npoints; i++ {
238+
for range npoints {
239239
v := dist.Rand()
240240
hist.Fill(v, 1)
241241
}
@@ -292,13 +292,13 @@ func ExampleTiledPlot() {
292292
dist := distuv.Normal{
293293
Mu: 0,
294294
Sigma: 1,
295-
Src: rand.New(rand.NewSource(0)),
295+
Src: rand.New(rand.NewPCG(0, 0)),
296296
}
297297

298298
newHist := func(p *hplot.Plot) {
299299
const npoints = 10000
300300
hist := hbook.NewH1D(20, -4, +4)
301-
for i := 0; i < npoints; i++ {
301+
for range npoints {
302302
v := dist.Rand()
303303
hist.Fill(v, 1)
304304
}
@@ -307,8 +307,8 @@ func ExampleTiledPlot() {
307307
p.Add(h)
308308
}
309309

310-
for i := 0; i < tp.Tiles.Rows; i++ {
311-
for j := 0; j < tp.Tiles.Cols; j++ {
310+
for i := range tp.Tiles.Rows {
311+
for j := range tp.Tiles.Cols {
312312
p := tp.Plot(j, i)
313313
p.X.Min = -5
314314
p.X.Max = +5
@@ -344,7 +344,7 @@ func ExampleTiledPlot_align() {
344344
j = int(math.Pow(10, float64(n)))
345345

346346
var pts []hbook.Point2D
347-
for ii := 0; ii < 10; ii++ {
347+
for ii := range 10 {
348348
pts = append(pts, hbook.Point2D{
349349
X: float64(i + ii),
350350
Y: float64(j + ii + 1),
@@ -354,8 +354,8 @@ func ExampleTiledPlot_align() {
354354

355355
}
356356

357-
for i := 0; i < tp.Tiles.Rows; i++ {
358-
for j := 0; j < tp.Tiles.Cols; j++ {
357+
for i := range tp.Tiles.Rows {
358+
for j := range tp.Tiles.Cols {
359359
p := tp.Plot(j, i)
360360
p.X.Min = -5
361361
p.X.Max = +5
@@ -398,13 +398,13 @@ func ExampleRatioPlot() {
398398
dist := distuv.Normal{
399399
Mu: 0,
400400
Sigma: 1,
401-
Src: rand.New(rand.NewSource(0)),
401+
Src: rand.New(rand.NewPCG(0, 0)),
402402
}
403403

404404
hist1 := hbook.NewH1D(20, -4, +4)
405405
hist2 := hbook.NewH1D(20, -4, +4)
406406

407-
for i := 0; i < npoints; i++ {
407+
for range npoints {
408408
v1 := dist.Rand() - 0.5
409409
v2 := dist.Rand() + 0.5
410410
hist1.Fill(v1, 1)
@@ -431,7 +431,7 @@ func ExampleRatioPlot() {
431431
rp.Top.Add(hplot.NewGrid())
432432

433433
hist3 := hbook.NewH1D(20, -4, +4)
434-
for i := 0; i < hist3.Len(); i++ {
434+
for i := range hist3.Len() {
435435
v1 := hist1.Value(i)
436436
v2 := hist2.Value(i)
437437
x1, _ := hist1.XY(i)
@@ -475,7 +475,7 @@ func ExampleH2D() {
475475
dist, ok := distmv.NewNormal(
476476
[]float64{0, 1},
477477
mat.NewSymDense(2, []float64{4, 0, 0, 2}),
478-
rand.New(rand.NewSource(1234)),
478+
rand.New(rand.NewPCG(1234, 1234)),
479479
)
480480
if !ok {
481481
log.Fatalf("error creating distmv.Normal")
@@ -484,7 +484,7 @@ func ExampleH2D() {
484484
v := make([]float64, 2)
485485
// Draw some random values from the standard
486486
// normal distribution.
487-
for i := 0; i < npoints; i++ {
487+
for range npoints {
488488
v = dist.Rand(v)
489489
h.Fill(v[0], v[1], 1)
490490
}
@@ -514,7 +514,7 @@ func ExampleS2D() {
514514
dist, ok := distmv.NewNormal(
515515
[]float64{0, 1},
516516
mat.NewSymDense(2, []float64{4, 0, 0, 2}),
517-
rand.New(rand.NewSource(1234)),
517+
rand.New(rand.NewPCG(1234, 1234)),
518518
)
519519
if !ok {
520520
log.Fatalf("error creating distmv.Normal")
@@ -525,7 +525,7 @@ func ExampleS2D() {
525525
v := make([]float64, 2)
526526
// Draw some random values from the standard
527527
// normal distribution.
528-
for i := 0; i < npoints; i++ {
528+
for range npoints {
529529
v = dist.Rand(v)
530530
s2d.Fill(hbook.Point2D{X: v[0], Y: v[1]})
531531
}
@@ -630,15 +630,15 @@ func ExampleBand() {
630630
dist := distuv.Normal{
631631
Mu: 0,
632632
Sigma: 1,
633-
Src: rand.New(rand.NewSource(0)),
633+
Src: rand.New(rand.NewPCG(0, 0)),
634634
}
635635

636636
topData := make(plotter.XYs, npoints)
637637
botData := make(plotter.XYs, npoints)
638638

639639
// Draw some random values from the standard
640640
// normal distribution.
641-
for i := 0; i < npoints; i++ {
641+
for i := range npoints {
642642
x := float64(i+1) / xmax
643643

644644
v1 := dist.Rand()
@@ -705,13 +705,13 @@ func ExampleH1D_withPlotBorders() {
705705
dist := distuv.Normal{
706706
Mu: 0,
707707
Sigma: 1,
708-
Src: rand.New(rand.NewSource(0)),
708+
Src: rand.New(rand.NewPCG(0, 0)),
709709
}
710710

711711
// Draw some random values from the standard
712712
// normal distribution.
713713
hist := hbook.NewH1D(20, -4, +4)
714-
for i := 0; i < npoints; i++ {
714+
for range npoints {
715715
v := dist.Rand()
716716
hist.Fill(v, 1)
717717
}

hplot/hplot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Use of this source code is governed by an MIT-style license
77
// that can be found in the LICENSE file.
88

9-
//go:generate go run github.com/campoy/embedmd -w README.md
9+
//go:generate go tool github.com/campoy/embedmd -w README.md
1010

1111
package hplot // import "go-hep.org/x/hep/hplot"
1212

lcio/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func ExampleWriter() {
9393
}
9494

9595
const NEVENTS = 1
96-
for ievt := 0; ievt < NEVENTS; ievt++ {
96+
for ievt := range NEVENTS {
9797
evt := lcio.Event{
9898
RunNumber: run.RunNumber,
9999
Detector: run.Detector,

lcio/lcio.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
// Package lcio provides read/write access to the LCIO data model.
66
package lcio // import "go-hep.org/x/hep/lcio"
77

8-
//go:generate go get github.com/campoy/embedmd
9-
//go:generate embedmd -w README.md
8+
//go:generate go tool github.com/campoy/embedmd -w README.md

0 commit comments

Comments
 (0)