gonum/plot

Heatmap and Mat support nil values

jefersonprediza opened this issue · 3 comments

Hi,

Implement null value support in the heatmap and mat.

For example, I collect information from log files, environment variables, devices status, etc. These sources may not contain data for a certain period of time. When the time serie array comes with a null value, the heatmap crashs because of the wrong dimension in mat.

2021/06/23 10:15:21 http: panic serving 127.0.0.1:44290: mat: dimension mismatch
goroutine 21 [running]:
net/http.(*conn).serve.func1(0xc0008d8820)
/usr/local/go/src/net/http/server.go:1824 +0x153
panic(0xdcabc0, 0xc000497440)
/usr/local/go/src/runtime/panic.go:971 +0x499
gonum.org/v1/gonum/mat.NewDense(...)
/home/jeferson/go/pkg/mod/gonum.org/v1/gonum@v0.9.2/mat/dense.go:55
bitbucket.org/prediza/prediza-ws/handler/plot.(*Heatmap).Get(0x1d4ee48, 0x106b340, 0xc00007c140, 0xc0002d6300)
/home/jeferson/go/src/bitbucket.org/prediza/prediza-ws/handler/plot/heatmap.go:135 +0x15c9
net/http.HandlerFunc.ServeHTTP(0xc000830270, 0x106b340, 0xc00007c140, 0xc0002d6300)

thanks for the report.

could you also post a minimal reproducer?
thanks again.

From the stack trace, this is does not appear to be an issue of a nil, a panic(mat.ErrShape) can only present when the data parameter to mat.NewDense is non-nil and the dims are non-zero. This looks like it is working as intended and has found a bug in the calling code; in this case the data should be conditioned correctly before the call and a decision made as to whether to actually call the plotting code. In any case, it's not at all clear what a heat map plotter that is nil or has no data should actually plot in the general case, so the decision for this should be left to the user.

The stack trace doesn't show any involvement of plotter.HeatMap, so this is probably more correctly filed in gonum/gonum. However, filed there as bug/request against mat, the likely outcome will be wontfix because it's working as intended, but I'll wait for a response from the reporter.

tentatively closing this.
(fill free to reopen otherwise)