Skip to content

Conversation

kortschak
Copy link
Member

Please take a look.

/cc @chewxy

@codecov-io
Copy link

Codecov Report

Merging #543 into master will increase coverage by 0.37%.
The diff coverage is 89.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #543      +/-   ##
==========================================
+ Coverage   68.77%   69.15%   +0.37%     
==========================================
  Files          50       51       +1     
  Lines        5208     5304      +96     
==========================================
+ Hits         3582     3668      +86     
- Misses       1456     1464       +8     
- Partials      170      172       +2
Impacted Files Coverage Δ
plotter/field.go 89.58% <89.58%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd8a204...8ca2bf2. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Apr 4, 2019

Codecov Report

Merging #543 into master will increase coverage by 0.37%.
The diff coverage is 89.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #543      +/-   ##
==========================================
+ Coverage   68.77%   69.15%   +0.37%     
==========================================
  Files          50       51       +1     
  Lines        5208     5304      +96     
==========================================
+ Hits         3582     3668      +86     
- Misses       1456     1464       +8     
- Partials      170      172       +2
Impacted Files Coverage Δ
plotter/field.go 89.58% <89.58%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd8a204...e4119b4. Read the comment docs.

@kortschak kortschak force-pushed the plotter/fields branch 4 times, most recently from 874ca5f to f7aefe5 Compare April 4, 2019 07:35
plotter/field.go Outdated
// Dims returns the dimensions of the grid.
Dims() (c, r int)

// Vector returns the value of a grid value at (c, r).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Vector returns the magnitude in the X and Y directions at grid column and row (c, r).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	// Vector returns the value of a vector field at (c, r).
	// It will panic if c or r are out of bounds for the field.

field.go is derived heavily from heat.go and there are copy/paste errors that reflect that. This is one of those.

plotter/field.go Outdated
// It will panic if c or r are out of bounds for the grid.
Vector(c, r int) XY

// X returns the coordinate for the column at the index x.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/index x/index c/g

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This will also need to be fixed in heat.go.

plotter/field.go Outdated
}

// NewField creates as new heat map plotter for the given data,
// using the provided palette.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provided palette?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

//
// If DrawGlyph is nil, a simple black arrow will
// be drawn.
DrawGlyph func(c vg.Canvas, v XY)
Copy link
Contributor

@ctessum ctessum Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user wants to change the color of the glyph based on the field magnitude? What if a user wants to scale the size of the glyph based on the square root of magnitude, or some other transform?

I think both of these things would be allowed if we made the field magnitude an argument here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe the normalized magnitude.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, actually, providing the row and column indexes as arguments would probably be better, because then the user can pull in whatever external information they need.

Copy link
Member Author

@kortschak kortschak Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user wants to change the colour based on the magnitude, they can calculate the magnitude from v. This was the major reason v was included (which is the normalised vector).

I don't like the idea of a completely free approach to transforms. It opens up whole new world of issues to have to answer. This is simple and works for the vast majority of cases with close to zero work for the user. Allowing scaling by other than linear seems to me like an anti-pattern; the two commonly used scalings are length and area (in that order). People are bad at assessing area compared to length (this is a reason why pie charts are bad).

I can see some merits in providing the row/column, but I need to think about it some more. I'm not sure the additional complexity wins much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I somehow missed the fact that v was already included as an argument.

@@ -0,0 +1,146 @@
// Copyright ©2019 The Gonum Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the examples more legible in godoc, it might make sense to split the examples and tests up into individual files. From the documentation:

A whole file example is a file that ends in _test.go and contains exactly one example function, no test or benchmark functions, and at least one other package-level declaration. When displaying such examples godoc will show the entire file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is another PR. The example code that this is adapted from, heat_test.go is the same. In fact I think they all are because the TestX funcs are in the same files.

func (f field) Vector(c, r int) plotter.XY { return f.fn(f.X(c), f.Y(r)) }
func (f field) X(c int) float64 {
if c < 0 || c >= f.c {
panic("index out of range")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"x index out of range"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is example code, but OK.

Same in heat_test.go.

}
func (f field) Y(r int) float64 {
if r < 0 || r >= f.r {
panic("index out of range")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"y index out of range"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

ctessum
ctessum previously approved these changes Apr 4, 2019
//
// If DrawGlyph is nil, a simple black arrow will
// be drawn.
DrawGlyph func(c vg.Canvas, v XY)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I somehow missed the fact that v was already included as an argument.

@kortschak
Copy link
Member Author

I'll wait for @sbinet as well.

sbinet
sbinet previously approved these changes Apr 5, 2019
Copy link
Member

@sbinet sbinet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (modulo 2 minor nit-picks)

@kortschak kortschak dismissed stale reviews from sbinet and ctessum via 8e747f1 April 5, 2019 10:15
@kortschak
Copy link
Member Author

PTAL

@kortschak
Copy link
Member Author

AppVeyor is horrifically slow here. Do we use your identity on that @sbinet? We probably shouldn't since you're doing other things as well. Do they have organisation accounts like travis does? I have to say, the service they have is pretty disappointing.

@sbinet
Copy link
Member

sbinet commented Apr 5, 2019

their handling of org accounts is a bit confusing, and, at the very least not very straighforward, indeed...

@kortschak kortschak merged commit f2023ba into master Apr 5, 2019
@kortschak kortschak deleted the plotter/fields branch April 9, 2019 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants