diff --git a/.ci/check-formatting.sh b/.ci/check-formatting.sh index 63445546..06617beb 100755 --- a/.ci/check-formatting.sh +++ b/.ci/check-formatting.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + test -z "$(goimports -d .)" if [[ -n "$(gofmt -s -l .)" ]]; then echo -e '\e[31mCode not gofmt simplified in:\n\n' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 176ab5d9..37b0986b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: name: Build strategy: matrix: - go-version: [1.18.x, 1.17.x] + go-version: [1.19.x, 1.18.x] platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} env: @@ -24,18 +24,18 @@ jobs: steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: ${{ env.GOPATH }}/src/gonum.org/v1/plot fetch-depth: 1 - name: Cache-Go - uses: actions/cache@v2 + uses: actions/cache@v3 with: # In order: # * Module download cache @@ -79,7 +79,6 @@ jobs: if: matrix.platform == 'ubuntu-latest' run: | go test -v ./... - test -z "$(gofmt -d .)" ./.ci/check-imports.sh ./.ci/test-coverage.sh @@ -95,4 +94,4 @@ jobs: - name: Upload-Coverage if: matrix.platform == 'ubuntu-latest' - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v2 diff --git a/appveyor.yml b/appveyor.yml index ea52248c..c26cb4a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ build: off image: Visual Studio 2019 -stack: go 1.17 +stack: go 1.18 clone_folder: c:\gopath\src\gonum.org\v1\plot diff --git a/cmpimg/cmpimg.go b/cmpimg/cmpimg.go index fb1a0d78..578537dc 100644 --- a/cmpimg/cmpimg.go +++ b/cmpimg/cmpimg.go @@ -151,9 +151,9 @@ func cmpImg(v1, v2 image.Image, delta float64) bool { // yiqEqApprox compares the colors of 2 pixels, in the NTSC YIQ color space, // as described in: // -// Measuring perceived color difference using YIQ NTSC -// transmission color space in mobile applications. -// Yuriy Kotsarenko, Fernando Ramos. +// Measuring perceived color difference using YIQ NTSC +// transmission color space in mobile applications. +// Yuriy Kotsarenko, Fernando Ramos. // // An electronic version is available at: // diff --git a/font/len.go b/font/len.go index bbc06e63..443f1c18 100644 --- a/font/len.go +++ b/font/len.go @@ -40,10 +40,11 @@ func Points(pt float64) Length { // e.g. "42cm" "2.4in" "66pt" // If no unit was given, ParseLength assumes it was (postscript) points. // Currently valid units are: -// mm (millimeter) -// cm (centimeter) -// in (inch) -// pt (point) +// +// - mm (millimeter) +// - cm (centimeter) +// - in (inch) +// - pt (point) func ParseLength(value string) (Length, error) { var unit Length = 1 switch { diff --git a/go.mod b/go.mod index ae6c4768..763556f9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gonum.org/v1/plot -go 1.17 +go 1.18 require ( gioui.org v0.0.0-20210308172011-57750fc8a0a6 @@ -10,14 +10,15 @@ require ( github.com/go-fonts/liberation v0.2.0 github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 github.com/go-pdf/fpdf v0.6.0 - golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 - golang.org/x/image v0.0.0-20220302094943-723b81ca9867 + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e + golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 gonum.org/v1/gonum v0.11.0 rsc.io/pdf v0.1.1 ) require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - golang.org/x/sys v0.0.0-20210304124612-50617c2ba197 // indirect + golang.org/x/exp/shiny v0.0.0-20220722155223-a9213eeb770e // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/go.sum b/go.sum index a8d4dba2..0471f771 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,11 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U 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-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs= golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/exp/shiny v0.0.0-20220722155223-a9213eeb770e h1:pkl1Ko5DrhA4ezwKwdnmO7H1sKmMy9qLuYKRjS7SlmE= +golang.org/x/exp/shiny v0.0.0-20220722155223-a9213eeb770e/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -57,8 +60,8 @@ golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+o golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867 h1:TcHcE0vrmgzNH1v3ppjcMGbhG5+9fMuvOmUYwNEF4q4= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 h1:/eM0PCrQI2xd471rI+snWuu251/+/jpBpZqir2mPdnU= +golang.org/x/image v0.0.0-20220722155232-062f8c9fd539/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -72,8 +75,9 @@ golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210304124612-50617c2ba197 h1:7+SpRyhoo46QjKkYInQXpcfxx3TYFEYkn131lwGE9/0= golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/palette/brewer/brewer.go b/palette/brewer/brewer.go index d7188214..8c19d71c 100644 --- a/palette/brewer/brewer.go +++ b/palette/brewer/brewer.go @@ -15,7 +15,6 @@ // // For more information see: // http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_learnMore.html -// package brewer // import "gonum.org/v1/plot/palette/brewer" import ( diff --git a/plot.go b/plot.go index fd093f8c..be19dd7e 100644 --- a/plot.go +++ b/plot.go @@ -494,7 +494,13 @@ func (p *Plot) NominalY(names ...string) { // // Supported formats are: // -// eps, jpg|jpeg, pdf, png, svg, tex and tif|tiff. +// - .eps +// - .jpg|.jpeg +// - .pdf +// - .png +// - .svg +// - .tex +// - .tif|.tiff func (p *Plot) WriterTo(w, h vg.Length, format string) (io.WriterTo, error) { c, err := draw.NewFormattedCanvas(w, h, format) if err != nil { @@ -509,7 +515,13 @@ func (p *Plot) WriterTo(w, h vg.Length, format string) (io.WriterTo, error) { // // Supported extensions are: // -// .eps, .jpg, .jpeg, .pdf, .png, .svg, .tex, .tif and .tiff. +// - .eps +// - .jpg|.jpeg +// - .pdf +// - .png +// - .svg +// - .tex +// - .tif|.tiff func (p *Plot) Save(w, h vg.Length, file string) (err error) { f, err := os.Create(file) if err != nil { diff --git a/plotter/boxplot.go b/plotter/boxplot.go index 31e612ad..2ecd8a7e 100644 --- a/plotter/boxplot.go +++ b/plotter/boxplot.go @@ -87,7 +87,7 @@ type BoxPlot struct { // NewBoxPlot returns a new BoxPlot that represents // the distribution of the given values. The style of // the box plot is that used for Tukey's schematic -// plots is ``Exploratory Data Analysis.'' +// plots in “Exploratory Data Analysis.” // // An error is returned if the boxplot is created with // no values. diff --git a/plotter/heat.go b/plotter/heat.go index d2129604..2b42486e 100644 --- a/plotter/heat.go +++ b/plotter/heat.go @@ -145,7 +145,7 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) { pImg.Plot(c, plt) } -// plotVectorized plots the heatmap using vector-based drawing. +// plotVectorized plots the heatmap using vector-based drawing. func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) { if h.Min > h.Max { panic("contour: invalid Z range: min greater than max") diff --git a/plotter/johnson.go b/plotter/johnson.go index 709f8df2..b7c1fd23 100644 --- a/plotter/johnson.go +++ b/plotter/johnson.go @@ -125,7 +125,6 @@ func min(a, b int) int { // algorithm. The implementation is from the pseudocode at // // http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm?oldid=642744644 -// type tarjan struct { g graph diff --git a/text/latex.go b/text/latex.go index 6a0ac0f9..8ddcb961 100644 --- a/text/latex.go +++ b/text/latex.go @@ -50,9 +50,9 @@ func (hdlr Latex) Lines(txt string) []string { } // Box returns the bounding box of the given non-multiline text where: -// - width is the horizontal space from the origin. -// - height is the vertical space above the baseline. -// - depth is the vertical space below the baseline, a positive number. +// - width is the horizontal space from the origin. +// - height is the vertical space above the baseline. +// - depth is the vertical space below the baseline, a positive number. func (hdlr Latex) Box(txt string, fnt font.Font) (width, height, depth vg.Length) { cnv := drawtex.New() face := hdlr.Fonts.Lookup(fnt, fnt.Size) diff --git a/text/plain.go b/text/plain.go index 406c7f49..5178e49a 100644 --- a/text/plain.go +++ b/text/plain.go @@ -37,9 +37,9 @@ func (hdlr Plain) Lines(txt string) []string { } // Box returns the bounding box of the given non-multiline text where: -// - width is the horizontal space from the origin. -// - height is the vertical space above the baseline. -// - depth is the vertical space below the baseline, a positive number. +// - width is the horizontal space from the origin. +// - height is the vertical space above the baseline. +// - depth is the vertical space below the baseline, a positive number. func (hdlr Plain) Box(txt string, fnt font.Font) (width, height, depth vg.Length) { face := hdlr.Fonts.Lookup(fnt, fnt.Size) ext := face.Extents() diff --git a/version.go b/version.go index d70fe47d..ba67b685 100644 --- a/version.go +++ b/version.go @@ -19,7 +19,9 @@ const root = "gonum.org/v1/plot" // // If a replace directive exists in the Gonum/plot go.mod, the replace will // be reported in the version in the following format: -// "version=>[replace-path] [replace-version]" +// +// "version=>[replace-path] [replace-version]" +// // and the replace sum will be returned in place of the original sum. // // The exact version format returned by Version may change in future. diff --git a/vg/draw/canvas.go b/vg/draw/canvas.go index 990a0db2..b62b1439 100644 --- a/vg/draw/canvas.go +++ b/vg/draw/canvas.go @@ -293,11 +293,11 @@ func New(c vg.CanvasSizer) Canvas { // image format. Supported formats need to be registered by importing one or // more of the following packages: // -// gonum.org/v1/plot/vg/vgeps // provides eps -// gonum.org/v1/plot/vg/vgimg // provides png, jpg|jpeg, tif|tiff -// gonum.org/v1/plot/vg/vgpdf // provides pdf -// gonum.org/v1/plot/vg/vgsvg // provides svg -// gonum.org/v1/plot/vg/vgtex // provides tex +// - gonum.org/v1/plot/vg/vgeps: provides eps +// - gonum.org/v1/plot/vg/vgimg: provides png, jpg|jpeg, tif|tiff +// - gonum.org/v1/plot/vg/vgpdf: provides pdf +// - gonum.org/v1/plot/vg/vgsvg: provides svg +// - gonum.org/v1/plot/vg/vgtex: provides tex func NewFormattedCanvas(w, h vg.Length, format string) (vg.CanvasWriterTo, error) { formats.RLock() defer formats.RUnlock() diff --git a/vg/len.go b/vg/len.go index 01d779e0..bee7c111 100644 --- a/vg/len.go +++ b/vg/len.go @@ -27,10 +27,11 @@ const ( // e.g. "42cm" "2.4in" "66pt" // If no unit was given, ParseLength assumes it was (postscript) points. // Currently valid units are: -// mm (millimeter) -// cm (centimeter) -// in (inch) -// pt (point) +// +// - mm (millimeter) +// - cm (centimeter) +// - in (inch) +// - pt (point) func ParseLength(value string) (Length, error) { return font.ParseLength(value) } diff --git a/vg/vggio/vggio_test.go b/vg/vggio/vggio_test.go index 259e53b8..ac107aa6 100644 --- a/vg/vggio/vggio_test.go +++ b/vg/vggio/vggio_test.go @@ -29,8 +29,8 @@ const deltaGio = 0.05 // empirical value from experimentation. // On GitHub Actions and on linux, that headless display may take some time to // be properly available and appears to be setup "on demand". // So we request it by trying to take a screenshot twice: -// - the first time around might fail -// - the second time shouldn't. +// - the first time around might fail +// - the second time shouldn't. func init() { if runtime.GOOS != "linux" { return diff --git a/vg/vgpdf/vgpdf.go b/vg/vgpdf/vgpdf.go index 67eef7b8..bc4fc69e 100644 --- a/vg/vgpdf/vgpdf.go +++ b/vg/vgpdf/vgpdf.go @@ -33,7 +33,7 @@ import ( // font files, needed by gofpdf to embed fonts in a PDF document. // We use cp1252 (code page 1252, Windows Western) to encode characters. // See: -// - https://en.wikipedia.org/wiki/Windows-1252 +// - https://en.wikipedia.org/wiki/Windows-1252 // // TODO: provide a Canvas-level func option to embed fonts with a user provided // code page schema? diff --git a/vg/vgsvg/vgsvg.go b/vg/vgsvg/vgsvg.go index 45ef2339..210920cb 100644 --- a/vg/vgsvg/vgsvg.go +++ b/vg/vgsvg/vgsvg.go @@ -13,7 +13,7 @@ // this issue. // // Alternatively, users may want to install the Liberation fonts on their system: -// - https://en.wikipedia.org/wiki/Liberation_fonts +// - https://en.wikipedia.org/wiki/Liberation_fonts package vgsvg // import "gonum.org/v1/plot/vg/vgsvg" import (