Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
caiw committed Oct 18, 2024
1 parent 74569d7 commit d4e69af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kymata/entities/functions.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d4e69af

Please sign in to comment.