-
Notifications
You must be signed in to change notification settings - Fork 8
/
chans_test.go
72 lines (67 loc) · 2.09 KB
/
chans_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package chans
import (
"math"
"testing"
"github.com/stretchr/testify/assert"
)
func TestVGGC_GFromV(t *testing.T) {
const step = .001
const maxRelativeDiff = .1
prevG := float32(math.NaN())
prevVM := float32(math.NaN())
var params VGCCParams
for vM := float32(0); vM < 2; vM += step {
g := params.GFromV(vM)
assert.Greater(t, g, float32(0), "for input %v", vM)
// should really be <= 100, but FastExp introduces some error
assert.LessOrEqual(t, g, float32(100.1), "for input %v", vM)
if !math.IsNaN(float64(prevG)) {
// check for discontinuities
assert.InEpsilon(t, prevG, g, maxRelativeDiff, "for inputs %v and %v", prevVM, vM)
// check for monotonicity
assert.LessOrEqual(t, g, prevG, "for inputs %v and %v", prevVM, vM)
}
prevG = g
prevVM = vM
}
}
func TestVGGC_MFromV(t *testing.T) {
const step = .01
const maxRelativeDiff = .1
prevM := float32(math.NaN())
prevVBio := float32(math.NaN())
var params VGCCParams
for vBio := float32(-100); vBio < 0; vBio += step {
m := params.MFromV(vBio)
assert.GreaterOrEqual(t, m, float32(0), "for input %v", vBio)
assert.LessOrEqual(t, m, float32(1), "for input %v", vBio)
if !math.IsNaN(float64(prevM)) {
// check for discontinuities
assert.InEpsilon(t, prevM, m, maxRelativeDiff, "for inputs %v and %v", prevVBio, vBio)
// check for monotonicity
assert.LessOrEqual(t, prevM, m, "for inputs %v and %v", prevVBio, vBio)
prevM = m
}
prevVBio = vBio
}
}
func TestVGGC_HFromV(t *testing.T) {
const step = .01
const maxRelativeDiff = .1
prevH := float32(math.NaN())
prevVBio := float32(math.NaN())
var params VGCCParams
for vBio := float32(-100); vBio < 0; vBio += step {
h := params.HFromV(vBio)
assert.GreaterOrEqual(t, h, float32(0), "for input %v", vBio)
assert.LessOrEqual(t, h, float32(1), "for input %v", vBio)
if !math.IsNaN(float64(prevH)) {
// check for discontinuities
assert.InEpsilon(t, prevH, h, maxRelativeDiff, "for inputs %v and %v", prevVBio, vBio)
// check for monotonicity
assert.LessOrEqual(t, h, prevH, "for inputs %v and %v", prevVBio, vBio)
prevH = h
}
prevVBio = vBio
}
}