mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
Merge pull request #1440 from dydysy/fix_dot_calc
FIX: [indicator] Possibly incorrect assignment
This commit is contained in:
commit
c74ba4f406
|
@ -327,29 +327,29 @@ func Dot(a interface{}, b interface{}, limit ...int) float64 {
|
||||||
aas = tp
|
aas = tp
|
||||||
isaf = false
|
isaf = false
|
||||||
default:
|
default:
|
||||||
panic("input should be either Series or float64")
|
panic("input should be either *Series or numbers")
|
||||||
}
|
}
|
||||||
switch tp := b.(type) {
|
switch tp := b.(type) {
|
||||||
case float64:
|
case float64:
|
||||||
bbf = tp
|
bbf = tp
|
||||||
isbf = true
|
isbf = true
|
||||||
case int32:
|
case int32:
|
||||||
aaf = float64(tp)
|
bbf = float64(tp)
|
||||||
isaf = true
|
isbf = true
|
||||||
case int64:
|
case int64:
|
||||||
aaf = float64(tp)
|
bbf = float64(tp)
|
||||||
isaf = true
|
isbf = true
|
||||||
case float32:
|
case float32:
|
||||||
aaf = float64(tp)
|
bbf = float64(tp)
|
||||||
isaf = true
|
isbf = true
|
||||||
case int:
|
case int:
|
||||||
aaf = float64(tp)
|
bbf = float64(tp)
|
||||||
isaf = true
|
isbf = true
|
||||||
case Series:
|
case Series:
|
||||||
bbs = tp
|
bbs = tp
|
||||||
isbf = false
|
isbf = false
|
||||||
default:
|
default:
|
||||||
panic("input should be either Series or float64")
|
panic("input should be either *Series or numbers")
|
||||||
|
|
||||||
}
|
}
|
||||||
l := 1
|
l := 1
|
||||||
|
|
|
@ -215,6 +215,10 @@ func TestDot(t *testing.T) {
|
||||||
assert.InDelta(t, out2, 3., 0.001)
|
assert.InDelta(t, out2, 3., 0.001)
|
||||||
out3 := Dot(3., &a, 2)
|
out3 := Dot(3., &a, 2)
|
||||||
assert.InDelta(t, out2, out3, 0.001)
|
assert.InDelta(t, out2, out3, 0.001)
|
||||||
|
out4 := Dot(&a, 3, 2)
|
||||||
|
assert.InDelta(t, out2, 3., 0.001)
|
||||||
|
out5 := Dot(3, &a, 2)
|
||||||
|
assert.InDelta(t, out4, out5, 0.001)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClone(t *testing.T) {
|
func TestClone(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user