From 05d446cb545f1b2397d799b3e0aab0aba87f5e3c Mon Sep 17 00:00:00 2001 From: dydysy <200615@gmail.com> Date: Wed, 6 Dec 2023 18:42:10 +0800 Subject: [PATCH] FIX: [indicator] Possibly incorrect assignment --- pkg/types/indicator.go | 20 ++++++++++---------- pkg/types/indicator_test.go | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/types/indicator.go b/pkg/types/indicator.go index 593f6bec8..839e9b3fc 100644 --- a/pkg/types/indicator.go +++ b/pkg/types/indicator.go @@ -327,29 +327,29 @@ func Dot(a interface{}, b interface{}, limit ...int) float64 { aas = tp isaf = false default: - panic("input should be either Series or float64") + panic("input should be either *Series or numbers") } switch tp := b.(type) { case float64: bbf = tp isbf = true case int32: - aaf = float64(tp) - isaf = true + bbf = float64(tp) + isbf = true case int64: - aaf = float64(tp) - isaf = true + bbf = float64(tp) + isbf = true case float32: - aaf = float64(tp) - isaf = true + bbf = float64(tp) + isbf = true case int: - aaf = float64(tp) - isaf = true + bbf = float64(tp) + isbf = true case Series: bbs = tp isbf = false default: - panic("input should be either Series or float64") + panic("input should be either *Series or numbers") } l := 1 diff --git a/pkg/types/indicator_test.go b/pkg/types/indicator_test.go index da328c666..d8c158f2a 100644 --- a/pkg/types/indicator_test.go +++ b/pkg/types/indicator_test.go @@ -215,6 +215,10 @@ func TestDot(t *testing.T) { assert.InDelta(t, out2, 3., 0.001) out3 := Dot(3., &a, 2) 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) {