本文整理汇总了Golang中github.com/ready-steady/assert.EqualWithin函数的典型用法代码示例。如果您正苦于以下问题:Golang EqualWithin函数的具体用法?Golang EqualWithin怎么用?Golang EqualWithin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EqualWithin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSimpleLinearNew
func TestSimpleLinearNew(t *testing.T) {
x := []float64{
3.181500e+02,
3.281500e+02,
3.381500e+02,
3.481500e+02,
3.581500e+02,
3.681500e+02,
3.781500e+02,
3.881500e+02,
3.981500e+02,
}
y := []float64{
5.459861e-01,
6.303621e-01,
7.325854e-01,
8.549895e-01,
1.000000e+00,
1.171091e+00,
1.373428e+00,
1.606733e+00,
1.873658e+00,
}
model := NewSimpleLinear(x, y)
assert.EqualWithin(model.α, -4.7845715178610932e+00, 1e-12, t)
assert.EqualWithin(model.β, +1.6395978333333290e-02, 1e-12, t)
}
开发者ID:ready-steady,项目名称:statistics,代码行数:29,代码来源:linear_test.go
示例2: TestListDelay
func TestListDelay(t *testing.T) {
platform, application, _ := system.Load(findFixture("002_040"))
profile := system.NewProfile(platform, application)
list := NewList(platform, application)
schedule := list.Compute(profile.Mobility)
delay := []float64{
0.0352, 0.0831, 0.0585, 0.0550, 0.0917, 0.0286, 0.0757, 0.0754,
0.0380, 0.0568, 0.0076, 0.0054, 0.0531, 0.0779, 0.0934, 0.0130,
0.0569, 0.0469, 0.0012, 0.0337, 0.0162, 0.0794, 0.0311, 0.0529,
0.0166, 0.0602, 0.0263, 0.0654, 0.0689, 0.0748, 0.0451, 0.0084,
0.0229, 0.0913, 0.0152, 0.0826, 0.0538, 0.0996, 0.0078, 0.0443,
}
start := []float64{
0.0000, 0.0582, 0.1533, 0.4349, 0.2238, 0.3855, 1.7419, 0.3365,
0.3365, 0.5019, 0.6554, 0.4251, 0.6820, 1.2139, 1.6966, 0.5727,
1.3128, 0.7837, 0.9856, 0.6067, 0.6554, 0.9998, 0.8456, 1.3128,
0.7481, 1.4890, 1.1766, 1.0992, 0.8917, 0.9856, 0.7837, 1.3847,
1.8648, 1.3847, 1.1766, 1.6373, 1.8010, 1.5810, 1.5622, 1.5810,
}
finish := make([]float64, len(start))
for i := range finish {
finish[i] = start[i] + (schedule.Finish[i] - schedule.Start[i]) + delay[i]
}
schedule = list.Delay(schedule, delay)
assert.EqualWithin(schedule.Start, start, 1e-15, t)
assert.EqualWithin(schedule.Finish, finish, 2e-15, t)
}
开发者ID:turing-complete,项目名称:time,代码行数:33,代码来源:list_test.go
示例3: TestKolmogorovSmirnovGaussian
func TestKolmogorovSmirnovGaussian(t *testing.T) {
data1 := []float64{
+1.8368909586194213e-01, -4.7615301661907383e-01,
+8.6202161155692203e-01, -1.3616944708707543e+00,
+4.5502955644433435e-01, -8.4870937993365902e-01,
-3.3488693896404770e-01, +5.5278334594455014e-01,
+1.0390906535049560e+00, -1.1176386832652081e+00,
+1.2606587091208963e+00, +6.6014314104697769e-01,
-6.7865553542687335e-02, -1.9522119789875436e-01,
-2.1760635014319193e-01, -3.0310762135174091e-01,
+2.3045624425105282e-02, +5.1290355848774699e-02,
+8.2606279021159545e-01, +1.5269766867333727e+00,
}
data2 := []float64{
+4.6691443568470004e-01, -2.0971333838873671e-01,
+6.2519035708762571e-01, +1.8322726300143696e-01,
-1.0297675435666211e+00, +9.4922183113102254e-01,
+3.0706191914670344e-01, +1.3517494209945566e-01,
+5.1524633552484855e-01, +2.6140632405538267e-01,
-9.4148577095543373e-01, -1.6233767280382774e-01,
-1.4605463433152618e-01, -5.3201137680882071e-01,
+1.6821035946631788e+00, -8.7572934616001730e-01,
-4.8381505011012110e-01, -7.1200454902742250e-01,
-1.1742123314568162e+00, -1.9223951753927476e-01,
}
rejected, pvalue, statistic := KolmogorovSmirnov(data1, data2, 0.05)
assert.Equal(rejected, false, t)
assert.EqualWithin(pvalue, 7.7095294467658659e-01, 1e-15, t)
assert.EqualWithin(statistic, 2.0000000000000007e-01, 1e-15, t)
}
开发者ID:postfix,项目名称:statistics-1,代码行数:33,代码来源:main_test.go
示例4: TestParabola
func TestParabola(t *testing.T) {
fixture := &fixtureParabola
algorithm, strategy := prepare(fixture)
surrogate := algorithm.Compute(fixture.target, strategy)
assert.Equal(surrogate.Nodes, fixture.surrogate.Nodes, t)
assert.EqualWithin(surrogate.Integral, fixture.surrogate.Integral, 1e-6, t)
assert.Equal(interpolation.Validate(surrogate.Indices, surrogate.Inputs,
fixture.grid), true, t)
values := algorithm.Evaluate(surrogate, fixture.points)
assert.EqualWithin(values, fixture.values, 1e-6, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:13,代码来源:main_test.go
示例5: TestListCompute
func TestListCompute(t *testing.T) {
platform, application, _ := system.Load(findFixture("002_040"))
profile := system.NewProfile(platform, application)
list := NewList(platform, application)
schedule := list.Compute(profile.Mobility)
mapping := []uint{
0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0,
1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0,
}
order := []uint{
0, 1, 2, 4, 7, 8, 5, 11, 3, 9, 15, 19, 20, 10, 12, 24, 30, 17, 22, 28, 29,
18, 21, 27, 34, 26, 13, 16, 23, 31, 33, 25, 38, 39, 37, 35, 14, 36, 6, 32,
}
start := []float64{
0.0000, 0.0230, 0.0350, 0.0910, 0.0470, 0.0790, 0.4220, 0.0680,
0.0680, 0.1030, 0.1530, 0.0900, 0.1720, 0.3150, 0.4040, 0.1170,
0.3360, 0.2040, 0.2590, 0.1380, 0.1530, 0.2720, 0.2190, 0.3360,
0.1850, 0.3640, 0.3040, 0.2920, 0.2340, 0.2590, 0.2040, 0.3510,
0.4250, 0.3510, 0.3040, 0.4000, 0.4150, 0.3880, 0.3770, 0.3880,
}
duration := []float64{
0.0230, 0.0120, 0.0120, 0.0120, 0.0210, 0.0110, 0.0180, 0.0230,
0.0110, 0.0140, 0.0190, 0.0150, 0.0130, 0.0210, 0.0110, 0.0210,
0.0150, 0.0150, 0.0130, 0.0150, 0.0210, 0.0200, 0.0150, 0.0100,
0.0190, 0.0130, 0.0110, 0.0120, 0.0250, 0.0150, 0.0180, 0.0190,
0.0140, 0.0130, 0.0260, 0.0220, 0.0100, 0.0160, 0.0110, 0.0120,
}
finish := make([]float64, len(start))
span := 0.0
for i := range start {
finish[i] = start[i] + duration[i]
if span < finish[i] {
span = finish[i]
}
}
assert.Equal(schedule.Cores, uint(2), t)
assert.Equal(schedule.Tasks, uint(40), t)
assert.EqualWithin(schedule.Span, span, 1e-15, t)
assert.Equal(schedule.Mapping, mapping, t)
assert.Equal(schedule.Order, order, t)
assert.EqualWithin(schedule.Start, start, 1e-15, t)
assert.EqualWithin(schedule.Finish, finish, 1e-15, t)
}
开发者ID:turing-complete,项目名称:time,代码行数:51,代码来源:list_test.go
示例6: TestParseRealIndex
func TestParseRealIndex(t *testing.T) {
cases := []struct {
line string
min float64
max float64
result []float64
}{
{"", 0, 1, nil},
{"[]", 0, 1, []float64{}},
{"[0, 0.1, 0.9, 1]", 0, 1, []float64{0.0, 0.1, 0.9, 1.0}},
{"[0, 0.1, 1.1]", 0, 1, nil},
{"[0:1]", 0, 1, []float64{0, 1}},
{"[0.1:0.2:1]", 0, 1, []float64{0.1, 0.3, 0.5, 0.7, 0.9}},
{"[0:0.2:1]", 0, 1, []float64{0.0, 0.2, 0.4, 0.6, 0.8, 1.0}},
{"[0:0.5:1.5]", 0, 1, nil},
{"[0, 0.2, end]", 0, 1, []float64{0.0, 0.2, 1.0}},
{"[0:0.2:end]", 0, 1, []float64{0.0, 0.2, 0.4, 0.6, 0.8, 1.0}},
{"[0:end]", 0, 1, []float64{0, 1}},
}
for _, c := range cases {
result, err := ParseRealIndex(c.line, c.min, c.max)
if c.result != nil {
assert.Success(err, t)
}
assert.EqualWithin(result, c.result, 1e-15, t)
}
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:28,代码来源:main_test.go
示例7: TestSolutionCompute
func TestSolutionCompute(t *testing.T) {
config, _ := config.New("fixtures/002_020.json")
system, _ := system.New(&config.System)
uncertainty, _ := uncertainty.NewEpistemic(system, &config.Uncertainty)
quantity, _ := quantity.New(system, uncertainty, &config.Quantity)
ni, no := quantity.Dimensions()
solution, _ := New(ni, no, &config.Solution)
surrogate := solution.Compute(quantity, quantity)
nn := surrogate.Surrogate.Nodes
assert.Equal(nn, uint(841), t)
grid := grid.NewClosed(ni)
nodes := grid.Compute(surrogate.Surrogate.Indices)
values := make([]float64, nn*no)
for i := uint(0); i < nn; i++ {
quantity.Compute(nodes[i*ni:(i+1)*ni], values[i*no:(i+1)*no])
}
assert.EqualWithin(values, solution.Evaluate(surrogate, nodes), 1e-15, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:25,代码来源:main_test.go
示例8: TestCompute
func TestCompute(t *testing.T) {
Q := []float64{318.15, 328.15, 338.15, 348.15, 358.15, 368.15, 378.15, 388.15, 398.15}
C := []float64{0.5460, 0.6304, 0.7326, 0.8550, 1.0000, 1.1711, 1.3734, 1.6067, 1.8737}
power := New(1.0, Q, C)
assert.EqualWithin(power.Compute(358.15), 1.088, 0.001, t)
}
开发者ID:turing-complete,项目名称:power,代码行数:7,代码来源:main_test.go
示例9: TestHat
func TestHat(t *testing.T) {
fixture := &fixtureHat
algorithm, strategy := prepare(fixture)
surrogate := algorithm.Compute(fixture.target, strategy)
assert.Equal(surrogate, fixture.surrogate, t)
values := algorithm.Evaluate(surrogate, fixture.points)
assert.EqualWithin(values, fixture.values, 1e-15, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:10,代码来源:main_test.go
示例10: TestExpectation
func TestExpectation(t *testing.T) {
data := []float64{
+5.3766713954610001e-01, +1.8338850145950865e+00,
-2.2588468610036481e+00, +8.6217332036812055e-01,
+3.1876523985898081e-01, -1.3076882963052734e+00,
-4.3359202230568356e-01, +3.4262446653864992e-01,
+3.5783969397257605e+00, +2.7694370298848772e+00,
}
assert.EqualWithin(Expectation(data), 6.2428219709029698e-01, 1e-15, t)
}
开发者ID:postfix,项目名称:statistics-1,代码行数:11,代码来源:moment_test.go
示例11: TestVariance
func TestVariance(t *testing.T) {
data := []float64{
+5.3766713954610001e-01, +1.8338850145950865e+00,
-2.2588468610036481e+00, +8.6217332036812055e-01,
+3.1876523985898081e-01, -1.3076882963052734e+00,
-4.3359202230568356e-01, +3.4262446653864992e-01,
+3.5783969397257605e+00, +2.7694370298848772e+00,
}
assert.EqualWithin(Variance(data), 3.1324921339484746e+00, 1e-15, t)
}
开发者ID:postfix,项目名称:statistics-1,代码行数:11,代码来源:moment_test.go
示例12: TestQuadrature
func TestQuadrature(t *testing.T) {
const (
a = -6.0
b = +6.0
)
nodes := uint(math.Ceil((float64(3) + 1.0) / 2.0))
value := quadrature(a, b, nodes, f)
assert.EqualWithin(value, F(b)-F(a), 1e-12, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:11,代码来源:quadrature_test.go
示例13: TestBaseForwardInvert
func TestBaseForwardInvert(t *testing.T) {
uncertainty := &base{
tasks: []uint{0, 1, 2},
lower: []float64{10.0, 20.0, 30.0},
upper: []float64{20.0, 30.0, 40.0},
nt: 3,
nu: 3,
nz: 2,
copula: &copula{
C: []float64{
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
},
D: []float64{
6.0, 5.0,
4.0, 3.0,
2.0, 1.0,
},
},
marginals: []distribution.Continuous{
distribution.NewUniform(0.0, 1.0),
distribution.NewUniform(0.0, 1.0),
distribution.NewUniform(0.0, 1.0),
},
}
forward := uncertainty.Forward([]float64{18.0, 21.0, 36.0})
assert.EqualWithin(forward, []float64{
6.664804998759882e-01,
7.313162037785672e-01,
}, 1e-14, t)
backward := uncertainty.Backward([]float64{0.45, 0.65})
assert.EqualWithin(backward, []float64{
1.921556679782504e+01,
2.953060310728164e+01,
3.973501094321997e+01,
}, 1e-14, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:41,代码来源:base_test.go
示例14: TestPartition
func TestPartition(t *testing.T) {
const (
n = 10
ε = 1e-14
)
power, schedule := prepare("002_040")
P, ΔT := power.Partition(schedule, ε)
assert.Equal(P, fixturePartition.P, t)
assert.EqualWithin(ΔT, fixturePartition.ΔT, 1e-15, t)
}
开发者ID:turing-complete,项目名称:power,代码行数:12,代码来源:main_test.go
示例15: TestInvert
func TestInvert(t *testing.T) {
n := uint(3)
a := []float64{1.0, -1.0, 0.0, 0.0, 5.0, 3.0, 2.0, 0.0, -9.0}
expectedA := []float64{
+8.823529411764706e-01, +1.764705882352941e-01, +5.882352941176472e-02,
-1.176470588235294e-01, +1.764705882352941e-01, +5.882352941176472e-02,
+1.960784313725490e-01, +3.921568627450981e-02, -9.803921568627452e-02,
}
assert.Equal(Invert(a, n), nil, t)
assert.EqualWithin(a, expectedA, 1e-15, t)
}
开发者ID:ready-steady,项目名称:linear,代码行数:13,代码来源:main_test.go
示例16: TestNew
func TestNew(t *testing.T) {
config, _ := config.New("fixtures/002_020.json")
system, _ := New(&config.System)
assert.Equal(system.Platform.Len(), 2, t)
assert.Equal(system.Application.Len(), 20, t)
schedule := system.schedule
assert.Equal(schedule.Mapping, []uint{
0, 1, 0, 0, 1, 1, 1, 0, 0, 1,
1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
}, t)
assert.Equal(schedule.Order, []uint{
0, 1, 2, 9, 12, 16, 18, 14, 17, 13,
15, 3, 5, 11, 19, 8, 7, 6, 4, 10,
}, t)
assert.EqualWithin(schedule.Start, []float64{
0.000, 0.010, 0.013, 0.187, 0.265, 0.218, 0.262, 0.260, 0.242, 0.051,
0.267, 0.237, 0.079, 0.152, 0.113, 0.170, 0.079, 0.141, 0.113, 0.242,
}, 1e-15, t)
assert.EqualWithin(schedule.Span, 0.291, 1e-15, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:22,代码来源:main_test.go
示例17: TestComputeTridiagonal1D
func TestComputeTridiagonal1D(t *testing.T) {
a := []float64{
4.8075817741978699e-01, 1.2692671000342037e-01, 4.9831340044932859e-01,
3.9611537773884853e-01, 8.4803219799756557e-01, 3.8361564524640535e-01,
4.2271936732562421e-01, 2.9871494846480506e-01, 6.0343086813946123e-01,
6.5050309033626463e-01, 6.2611305300575382e-01, 4.9016643252911518e-01,
6.3228557723272305e-01, 8.0881918292978749e-03, 9.8142184023407009e-01,
3.0011820727343141e-01, 1.0221196095348672e-01, 1.7152991176879773e-01,
6.3234800301520455e-01, 6.4222978064709224e-01,
}
b := []float64{
1.4305400424536181e+00, 1.1546425268361689e+00, 1.5528249265311795e+00,
1.5046909633814507e+00, 1.3106321971636674e+00, 1.7723433981144341e+00,
1.0930877721506009e+00, 1.8067166712036105e+00, 1.4064057825267366e+00,
1.2810478325153505e+00, 1.9576080656029342e+00, 1.6020009934522998e+00,
1.9283873223117676e+00, 1.5668820259614546e+00, 1.4354500051833838e+00,
1.2600111255480502e+00, 1.4573886219153447e+00, 1.0769003298984701e+00,
1.2457299327768727e+00, 1.7477107763931770e+00,
}
c := []float64{
2.8548654494460557e-01, 5.8540758620217703e-01, 2.6850381977534676e-01,
6.9258609074529653e-01, 3.1247923637358188e-01, 9.0156663656333069e-01,
6.1005182073414899e-01, 3.7766783517906743e-01, 9.3237166831823881e-01,
5.8777963759554253e-01, 4.6097285394375520e-01, 2.1253215171767503e-01,
2.8937226325800802e-01, 1.2110782971154588e-01, 7.6345100838619318e-01,
9.4948181851599811e-01, 9.2046644452877935e-01, 9.4207843361454224e-01,
5.5613288144227369e-01, 3.2889132147476241e-01,
}
d := []float64{
5.4345703792352307e-01, 2.5206603256969351e-01, 6.7212010426701829e-01,
5.5742791550815585e-01, 1.5338438683979383e-01, 1.3141853627070477e-01,
2.1725351445739172e-01, 3.0696424588099869e-01, 6.5854065921020499e-01,
5.4972430745083167e-01, 6.8185426479854760e-01, 6.4746979094442436e-01,
3.7339166209360886e-01, 5.5263882037533685e-01, 4.5130602770887251e-01,
5.3739081485328155e-01, 3.0980792962149784e-01, 1.1107555117435641e-01,
7.5049154682465413e-01, 3.4499665786432776e-01,
}
x := []float64{
+3.8743269018574988e-01, -1.8416124759605874e-02, +3.2427337332838657e-01,
+2.4678206444367387e-01, +7.8428909904907917e-02, -5.2310318986601989e-02,
+2.5837172936714375e-01, -1.1942347907589732e-01, +4.4350329009194173e-01,
+1.1988956633676386e-01, +2.7879399381445569e-01, +2.7335327852770996e-01,
+1.2095495317582093e-01, +5.0822993667190834e-02, +5.1938776470139614e-01,
-3.1033791506044228e-01, +4.5485802026695138e-01, -2.7594190219192083e-01,
+6.5046602806975073e-01, -3.7949205847255349e-02,
}
assert.EqualWithin(ComputeTridiagonal(a, b, c, d), x, 1e-15, t)
}
开发者ID:ready-steady,项目名称:linear,代码行数:49,代码来源:tridiagonal_test.go
示例18: TestNewProfile
func TestNewProfile(t *testing.T) {
platform, application, _ := Load(findFixture("002_040"))
profile := NewProfile(platform, application)
mobility := []float64{
0.0000, 0.0000, 0.0000, 0.0445, 0.0000, 0.0140, 0.1145, 0.0000,
0.0095, 0.0000, 0.0145, 0.0140, 0.0140, 0.0280, 0.0740, 0.0000,
0.0280, 0.0140, 0.0225, 0.0000, 0.0000, 0.0225, 0.0140, 0.0310,
0.0000, 0.0380, 0.0260, 0.0225, 0.0140, 0.0140, 0.0000, 0.0280,
0.1490, 0.0340, 0.0225, 0.0520, 0.0280, 0.0435, 0.0380, 0.0380,
}
assert.EqualWithin(profile.Mobility, mobility, 1e-15, t)
}
开发者ID:turing-complete,项目名称:system,代码行数:15,代码来源:profile_test.go
示例19: TestInverse
func TestInverse(t *testing.T) {
m := uint(3)
A := []float64{
1.0, 2.0, 3.0,
2.0, 4.0, 5.0,
3.0, 5.0, 6.0,
}
U := make([]float64, m*m)
Λ := make([]float64, m)
err := decomposition.SymmetricEigen(A, U, Λ, m)
assert.Equal(err, nil, t)
err = matrix.Invert(A, m)
assert.Equal(err, nil, t)
I, err := invert(U, Λ, m)
assert.Equal(err, nil, t)
assert.EqualWithin(A, I, 1e-14, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:21,代码来源:support_test.go
示例20: TestNewEpistemic
func TestNewEpistemic(t *testing.T) {
const (
nt = 10
σ = 0.2
)
config, _ := config.New("fixtures/001_010.json")
system, _ := system.New(&config.System)
reference := system.ReferenceTime()
uncertainty, _ := NewEpistemic(system, &config.Uncertainty)
point := make([]float64, nt)
value := make([]float64, nt)
for i := 0; i < nt; i++ {
α := float64(i) / (nt - 1)
point[i] = α
value[i] = (1.0 - σ + 2.0*σ*α) * reference[i]
}
assert.EqualWithin(uncertainty.Backward(point), value, 1e-15, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:21,代码来源:main_test.go
注:本文中的github.com/ready-steady/assert.EqualWithin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论