Skip to content

Commit

Permalink
fixed python codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
matt200-ok committed Jan 13, 2025
1 parent 02be1b0 commit 19b9ff4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions binding/python/test_cobra.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ def test_process(self):
self._cobra.sample_rate)

num_frames = len(audio) // self._cobra.frame_length
probs = [ 0.0 ] * num_frames
probs = [0.0] * num_frames
for i in range(num_frames):
frame = audio[i * self._cobra.frame_length:(i + 1) * self._cobra.frame_length]
probs[i] = self._cobra.process(frame)

labels = [ 0 ] * num_frames
labels[10:28] = [ 1 ] * 18
labels = [0] * num_frames
labels[10:28] = [1] * 18

loss = sum([ l * math.log(p) + (1 - l) * math.log(1 - p) for l, p in zip(labels, probs)]) / num_frames
loss = sum([label * math.log(prob) + (1 - label) * math.log(1 - prob)
for label, prob in zip(labels, probs)]) / num_frames
self.assertLess(loss, 0.1)

def test_version(self):
Expand Down

0 comments on commit 19b9ff4

Please sign in to comment.