Error in gonum.org/v1/plot code that used to work #198
Comments
|
FYI:
And that seems to be the difference between what go/types.Type and reflect.Type are seeing. Still unclear why there is a difference between gomacro and gophernotes. |
|
One possible difference is that gophernotes no longer includes a vendored copy of gomacro. This may result in using a possibly outdated version of gomacro in any of the following cases:
That's why the installation procedure contains an explicit
To check if that's what happened in your case, you can clean your home directory with
then download and compile gophernotes with
examine the output to find which version of gomacro gets downloaded, then proceed with the rest of the installation as usual (copying files into ~/.local/share/jupyter/kernels/gophernotes). If this does not solve your issue, please post the output of the installation procedure, and I will investigate further. |
|
Hi, thanks for your quick response, as always. So I think there are two different issues here. The first was some stale go mod cache issues as you pointed out above. To get past that, I've installed all of this on a fresh macOS laptop that has never had any of this installed. The result is that gomacro is now failing in the same way as gophernotes. So that mystery is solved. But that failure remains. Here is a simpler reproduction of the issue. This go program runs perfectly ( package main
import (
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"image/color"
"log"
)
func main() {
groupA := plotter.Values{20, 35, 30, 35, 27}
p, err := plot.New()
if err != nil {
log.Panic(err)
}
p.Title.Text = "Bar chart"
p.Y.Label.Text = "Heights"
w := vg.Points(8)
barsA, err := plotter.NewBarChart(groupA, w)
if err != nil {
log.Panic(err)
}
barsA.Color = color.RGBA{R: 255, A: 255}
barsA.Offset = -w / 2
p.Add(barsA)
p.Legend.Add("A", barsA)
err = p.Save(300, 250, "barChart.png")
if err != nil {
log.Panic(err)
}
}However, the same code (with the
Here's the code in import (
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"image/color"
"log"
)
groupA := plotter.Values{20, 35, 30, 35, 27}
p, err := plot.New()
if err != nil {
log.Panic(err)
}
p.Title.Text = "Bar chart"
p.Y.Label.Text = "Heights"
w := vg.Points(8)
barsA, err := plotter.NewBarChart(groupA, w)
if err != nil {
log.Panic(err)
}
barsA.Color = color.RGBA{R: 255, A: 255}
barsA.Offset = -w / 2
p.Add(barsA)
p.Legend.Add("A", barsA)
err = p.Save(300, 250, "barChart.png")
if err != nil {
log.Panic(err)
}As I said in the OP, this all used to work fine, so something in gomacro/gophernotes seems to have recently changed to break this case. The only clue I can offer is it seems to have something to do with recognizing variadic methods as matching interfaces. Thanks for looking into it! |
|
Here's a gist with the same code + failure in gophernotes: https://gist.github.com/vsivsi/30f8bd862c1faef7a7710764b98d80b0 |
|
Thanks for the detailed report :) I will investigate it as soon as possible. Well, at least gophernotes and gomacro have the same behavior now, although it's wrong. An unrelated note: there's no need to strip |
|
Hi, @cosmos72 I hope you are staying safe and healthy! Just checking in to see if there's any progress on this issue or anything I can do to help. I've thought about doing a binary search in the commit history to at least narrow down when this broke and what change(s) caused it. Would that be helpful to you? |
|
I am fine, thanks! Yes, a binary search would help a lot, thanks for the offer! If you do it, please use gomacro git repository - using gophernotes would just land you on one of the few commits where gomacro is updated massively (tens of commits are squashed to a single one) |
|
Yes, we are also stuck at home, so time to find some bugs! Ok, I followed your advice and did this work in gomacro only, and have been able to trace the problem to the commit when module support was added: cosmos72/gomacro@caa3eae Prior to that, the test code above worked fine, but of course the plot libraries had to be separately installed in the GOPATH. i.e. And since that commit, the test code continues to work fine, so long as the plot library is installed in the GOPATH, even when using the new module support. But if the plot libs have never been installed in the GOPATH, then the repro code above fails, for every commit since the module support was added. I have verified this using the official golang Docker container for go 1.13.9 So, for example, if you start a container with the official go release from Dockerhub:
And then in the container run:
You get:
Which reproduces this issue. But if you install the plotting library in the GOPATH first:
You get the output below and the plot image is properly written to the output file:
You get the same behavior with both the first commit supporting modules and the current latest one, so this issue has remained static since Nov 18, 2019 when it first appeared. cosmos72/gomacro@caa3eae It is curious that having the plotting libraries in the GOPATH has any effect on gomacro when the module mode is engaged, as it appears to download and build them the same either way, but it seems that the dependencies between them are not being resolved by the module loader in the same way, depending on the contents of the GOPATH. It is also the case that if you disable module support in gomacro with So this problem was hidden to me for a time, because I had installed plotting libraries from the pre-module days. But when I moved to a new computer and left that state behind, I started seeing failures. |
|
Sigh. |
|
Sorry to hear that. It seems for now I should just proceed with the modules support disabled. Please let me know if there's anything more I can do to help. |

Hi, After not using gophernotes for a month or so, something has changed so that example code for gonum.org/v1/plot no longer runs properly in gophernotes, but continues to run fine in the latest gomacro.
Reproduction from this example code:
Which panics with:
The code above works fine on the latest commit of
gomacroby itself, I only see this failure in a fresh install of gophernotes.I've tried clearing all of the state in
~/go/pkgand~/go/src/gomacro.importsbut that didn't resolve anything. Has gophernotes fallen behindgomacroin some respect and this is a symptom?The text was updated successfully, but these errors were encountered: