You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow up on #108 on why the test failed randomly. I got the following error:
--- FAIL: TestFloat64Engine_makeArray (0.00s)
panic: runtime error: index out of range [0] with length 0 [recovered]
panic: runtime error: index out of range [0] with length 0
goroutine 128 [running]:
testing.tRunner.func1.1(0x14a0a80, 0xc000244080)
/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:999 +0x461
testing.tRunner.func1(0xc00045c240)
/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:1002 +0x606
panic(0x14a0a80, 0xc000244080)
/opt/hostedtoolcache/go/1.14.15/x64/src/runtime/panic.go:975 +0x3e3
gorgonia.org/tensor.(*array).Uintptr(...)
/home/runner/work/tensor/tensor/array.go:158
gorgonia.org/tensor.array.Data(0x1e438f0, 0x0, 0x0, 0x169fc40, 0x13eb260, 0x13f33f7, 0x13f33e0)
/home/runner/work/tensor/tensor/array.go:167 +0x211
gorgonia.org/tensor.TestFloat64Engine_makeArray.func1(0x0, 0x0)
/home/runner/work/tensor/tensor/defaultenginefloat64_test.go:26 +0x199
reflect.Value.call(0x140fb00, 0xc000466040, 0x13, 0x14f71eb, 0x4, 0xc0001b8000, 0x1, 0x1, 0x49d7c2, 0x53aa60, ...)
/opt/hostedtoolcache/go/1.14.15/x64/src/reflect/value.go:460 +0x967
reflect.Value.Call(0x140fb00, 0xc000466040, 0x13, 0xc0001b8000, 0x1, 0x1, 0xc000188000, 0x0, 0x0)
/opt/hostedtoolcache/go/1.14.15/x64/src/reflect/value.go:321 +0xd4
testing/quick.Check(0x140fb00, 0xc000466040, 0x0, 0x4dce27, 0x47817b)
/opt/hostedtoolcache/go/1.14.15/x64/src/testing/quick/quick.go:290 +0x27a
gorgonia.org/tensor.TestFloat64Engine_makeArray(0xc00045c240)
/home/runner/work/tensor/tensor/defaultenginefloat64_test.go:38 +0xac
testing.tRunner(0xc00045c240, 0x1534a08)
/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:1050 +0x1ec
created by testing.(*T).Run
/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:1095 +0x538
After looking into it, it seems that quick.Check passes a random value for the size parameter to the test function. In this specific instance that random value was 0. This size is then used to create an array. And some of the functions don't work if the array has a length of 0.
Fun fact: this has a 1 in 65536 chance of occurring. This happened to me twice now. I don't think the chances are evenly distributed.
This can be fixed two ways:
Make array work with 0 as a size. (probably hard to do while keeping it efficient)
Make sure the tests don't pass in 0. And make sure that the makeArray doesn't get called with 0 (or less) as its size argument by returning an error earlier.
I think there are some other tests that can cause similar errors.
I am not working on fixing this at the moment so feel free to work on this issue if you're interested.
The text was updated successfully, but these errors were encountered:
MarkKremer
changed the title
Flaky test
Random index out of range [0] with length 0 error in some tests
Mar 29, 2021
Follow up on #108 on why the test failed randomly. I got the following error:
After looking into it, it seems that
quick.Check
passes a random value for the size parameter to the test function. In this specific instance that random value was 0. This size is then used to create an array. And some of the functions don't work if the array has a length of 0.Fun fact:
this has a 1 in 65536 chance of occurring.This happened to me twice now. I don't think the chances are evenly distributed.This can be fixed two ways:
0
as a size. (probably hard to do while keeping it efficient)0
. And make sure that the makeArray doesn't get called with0
(or less) as its size argument by returning an error earlier.I think there are some other tests that can cause similar errors.
I am not working on fixing this at the moment so feel free to work on this issue if you're interested.
The text was updated successfully, but these errors were encountered: