diff --git a/kymata/entities/functions.py b/kymata/entities/functions.py index d811f123..9598d145 100644 --- a/kymata/entities/functions.py +++ b/kymata/entities/functions.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from math import floor -from numpy import floor as np_floor, arange, clip, zeros +from numpy import floor as np_floor, arange, zeros from numpy.typing import NDArray @@ -40,7 +40,7 @@ def resampled(self, rate_hz: float): resampled_values = self.values[idxs] else: # Upsampling - new_length = int(len(self.values) / ratio) + new_length = floor(len(self.values) / ratio) resampled_values = zeros(new_length) for i in range(new_length): diff --git a/tests/test_functions.py b/tests/test_functions.py index 3d5e3f28..16385f28 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -17,6 +17,7 @@ def test_integer_subsample(): f_resampled = f.resampled(new_sample_rate) assert f_resampled.sample_rate == new_sample_rate assert len(f.values) / downsample_ratio == len(f_resampled.values) + assert array_equal(f_resampled.values, array(range(0, 100, 2))) def test_noninteger_downsample():