Skip to content

palette/moreland: possible panic for Palette method #798

@Juneezee

Description

@Juneezee

Minimal reproducible example:

package plotter_test

import (
	"testing"

	"gonum.org/v1/plot/palette/moreland"
)

func TestPalettePanic(t *testing.T) {
	minVal := 0.3402859786606234
	maxVal := 15.322841335211892
	n := 15

	t.Run("moreland.SmoothBlueRed panic", func(t *testing.T) {
		colors := moreland.SmoothBlueRed()
		colors.SetMin(minVal)
		colors.SetMax(maxVal)
		colors.Palette(n)
	})

	t.Run("moreland.Kindlmann panic", func(t *testing.T) {
		colors := moreland.Kindlmann()
		colors.SetMin(minVal)
		colors.SetMax(maxVal)
		colors.Palette(n)
	})
}

moreland.SmoothBlueRed:

=== RUN   TestPalettePanic
=== RUN   TestPalettePanic/moreland.SmoothBlueRed_panic
--- FAIL: TestPalettePanic/moreland.SmoothBlueRed_panic (0.00s)

--- FAIL: TestPalettePanic (0.00s)
panic: palette: specified value > maximum [recovered]
	panic: palette: specified value > maximum

goroutine 7 [running]:
testing.tRunner.func1.2({0x6d8d20, 0xe61110})
	/usr/local/go/src/testing/testing.go:1734 +0x21c
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1737 +0x35e
panic({0x6d8d20?, 0xe61110?})
	/usr/local/go/src/runtime/panic.go:792 +0x132
gonum.org/v1/plot/palette/moreland.smoothDiverging.Palette({{0x4054000000000000, 0x3ff147ae147ae148, 0xbff199999999999a}, {0x4054000000000000, 0x3ff147ae147ae148, 0x3fe0000000000000}, 0x4056000000000000, 0x3ff0000000000000, 0x3fd5c73ed7689f70, 0x402ea54b75a11069, ...}, ...)
	/home/jun/Desktop/github/waiting-for-pr/plot/palette/moreland/smooth.go:180 +0x1ab
gonum.org/v1/plot/plotter_test.TestPalettePanic.func1(0xc0002061c0?)
	/home/jun/Desktop/github/waiting-for-pr/plot/plotter/panic_test.go:18 +0x1b2
testing.tRunner(0xc0002061c0, 0xc00001e3e0)
	/usr/local/go/src/testing/testing.go:1792 +0xf4
created by testing.(*T).Run in goroutine 6
	/usr/local/go/src/testing/testing.go:1851 +0x413

moreland.Kindlmann:

=== RUN   TestPalettePanic
=== RUN   TestPalettePanic/moreland.Kindlmann_panic
--- FAIL: TestPalettePanic/moreland.Kindlmann_panic (0.00s)

--- FAIL: TestPalettePanic (0.00s)
panic: palette: specified value > maximum [recovered]
	panic: palette: specified value > maximum

goroutine 7 [running]:
testing.tRunner.func1.2({0x6d8d20, 0xe61110})
	/usr/local/go/src/testing/testing.go:1734 +0x21c
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1737 +0x35e
panic({0x6d8d20?, 0xe61110?})
	/usr/local/go/src/runtime/panic.go:792 +0x132
gonum.org/v1/plot/palette/moreland.luminance.Palette({{0xc000216000, 0xb, 0xb}, {0xc000218000, 0xb, 0xb}, 0x3ff0000000000000, 0x3fd5c73ed7689f70, 0x402ea54b75a11069}, 0xf)
	/home/jun/Desktop/github/waiting-for-pr/plot/palette/moreland/luminance.go:186 +0x177
gonum.org/v1/plot/plotter_test.TestPalettePanic.func2(0xc0002061c0?)
	/home/jun/Desktop/github/waiting-for-pr/plot/plotter/panic_test.go:25 +0x7f
testing.tRunner(0xc0002061c0, 0xc00001e4a0)
	/usr/local/go/src/testing/testing.go:1792 +0xf4
created by testing.(*T).Run in goroutine 6
	/usr/local/go/src/testing/testing.go:1851 +0x413

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions