MCPcopy Index your code
hub / github.com/gonum/plot / TestContourPaths

Function TestContourPaths

plotter/contour_test.go:147–182  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestContourPaths(t *testing.T) {
148 m := unitGrid{mat.NewDense(3, 4, []float64{
149 2, 1, 4, 3,
150 6, 7, 2, 5,
151 9, 10, 11, 12,
152 })}
153
154 levels := []float64{1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5}
155
156 var (
157 wantClosed = 2
158 gotClosed int
159 )
160
161 got := contourPaths(m, levels, unity, unity)
162 for l, p := range got {
163 sort.Sort(byLength(p))
164 for i, c := range p {
165 if isLoop(c) && isLoop(wantContours[l][i]) {
166 if !circularPermutations(c[1:], wantContours[l][i][1:]) {
167 t.Errorf("unexpected path:\n\tgot:%+v\n\twant:%+v", c, wantContours[l][i])
168 }
169 } else if !reflect.DeepEqual(c, wantContours[l][i]) && !reflect.DeepEqual(c, reverseOfPath(wantContours[l][i])) {
170 t.Errorf("unexpected path:\n\tgot:%+v\n\twant:%+v", c, wantContours[l][i])
171 }
172
173 if isLoop(c) {
174 gotClosed++
175 }
176 }
177 }
178
179 if gotClosed != wantClosed {
180 t.Errorf("unexpected number of loops: got:%d want:%d", gotClosed, wantClosed)
181 }
182}
183
184type byLength []vg.Path
185

Callers

nothing calls this directly

Calls 5

contourPathsFunction · 0.85
byLengthTypeAlias · 0.85
isLoopFunction · 0.85
circularPermutationsFunction · 0.85
reverseOfPathFunction · 0.85

Tested by

no test coverage detected