kopia lustrzana https://github.com/corrscope/corrscope
Rename Wave.get_around() subsampling to stride
rodzic
b755cb0f12
commit
dcc705f0c2
|
@ -94,12 +94,12 @@ class Wave:
|
|||
|
||||
return out
|
||||
|
||||
def get_around(self, sample: int, region_nsamp: int, subsampling: int):
|
||||
def get_around(self, sample: int, region_nsamp: int, stride: int):
|
||||
""" Copies self.data[...] """
|
||||
region_nsamp *= subsampling
|
||||
region_nsamp *= stride
|
||||
end = sample + region_nsamp // 2
|
||||
begin = end - region_nsamp
|
||||
return self._get(begin, end, subsampling)
|
||||
return self._get(begin, end, stride)
|
||||
|
||||
def get_s(self) -> float:
|
||||
"""
|
||||
|
|
|
@ -35,7 +35,7 @@ def test_channel_subsampling(
|
|||
Wave = mocker.patch.object(ovgenpy.channel, 'Wave')
|
||||
wave = Wave.return_value
|
||||
|
||||
def get_around(sample: int, region_nsamp: int, subsampling: int):
|
||||
def get_around(sample: int, region_nsamp: int, stride: int):
|
||||
return np.zeros(region_nsamp)
|
||||
|
||||
wave.get_around.side_effect = get_around
|
||||
|
|
|
@ -41,12 +41,12 @@ def test_wave_subsampling():
|
|||
wave = Wave(None, 'tests/sine440.wav')
|
||||
# period = 48000 / 440 = 109.(09)*
|
||||
|
||||
wave.get_around(1000, region_nsamp=501, subsampling=4)
|
||||
wave.get_around(1000, region_nsamp=501, stride=4)
|
||||
# len([:region_len:subsampling]) == ceil(region_len / subsampling)
|
||||
# If region_len % subsampling != 0, len() != region_len // subsampling.
|
||||
|
||||
subsampling = 4
|
||||
region = 100 # diameter = region * subsampling
|
||||
stride = 4
|
||||
region = 100 # diameter = region * stride
|
||||
for i in [-1000, 50000]:
|
||||
data = wave.get_around(i, region, subsampling)
|
||||
data = wave.get_around(i, region, stride)
|
||||
assert (data == 0).all()
|
||||
|
|
Ładowanie…
Reference in New Issue