From 3b769c30596bf8298960a982659c918cbef0f15a Mon Sep 17 00:00:00 2001 From: Aditya Ujeniya Date: Wed, 4 Dec 2024 14:19:56 +0100 Subject: [PATCH] fix: Update to resampler handling different resolutions --- pkg/resampler/resampler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/resampler/resampler.go b/pkg/resampler/resampler.go index 26cead0..192e56f 100644 --- a/pkg/resampler/resampler.go +++ b/pkg/resampler/resampler.go @@ -9,7 +9,7 @@ import ( ) func SimpleResampler(data []schema.Float, old_frequency int64, new_frequency int64) ([]schema.Float, error) { - if old_frequency == 0 || new_frequency == 0 { + if old_frequency == 0 || new_frequency == 0 || new_frequency <= old_frequency { return nil, errors.New("either old or new frequency is set to 0") } @@ -37,7 +37,7 @@ func SimpleResampler(data []schema.Float, old_frequency int64, new_frequency int // Adapted from https://github.com/haoel/downsampling/blob/master/core/lttb.go func LargestTriangleThreeBucket(data []schema.Float, old_frequency int, new_frequency int) ([]schema.Float, int, error) { - if old_frequency == 0 || new_frequency == 0 { + if old_frequency == 0 || new_frequency == 0 || new_frequency <= old_frequency { return data, old_frequency, nil }