Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two draft unit test scripts (on "frame2real" and "tensor2vectorreal") from the Auxillary section of UTs #1166

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
47 changes: 47 additions & 0 deletions test/src/unittests/standard/test_frametoreal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python

# Copyright (C) 2006-2021 Music Technology Group - Universitat Pompeu Fabra
#
# This file is part of Essentia
#
# Essentia is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the Affero GNU General Public License
# version 3 along with this program. If not, see http://www.gnu.org/licenses/


from essentia_test import *

class TestFrameToReal(TestCase):

def testInvalidParam(self):
self.assertConfigureFails(FrameToReal(), {'frameSize': -1})
self.assertConfigureFails(FrameToReal(), {'hopSize': -1})
self.assertConfigureFails(FrameToReal(), {'frameSize': 0})
self.assertConfigureFails(FrameToReal(), {'hopSize': 0})

# extreme conditions
def testEmpty(self):
self.assertRaises(RuntimeError, lambda: FrameToReal()([]))

def testHopSize(self):
found = FrameToReal(frameSize=100, hopSize = 60)(ones(1024))
self.assertEqual(len(found), 60)


def testSmallHopSize(self):
found = FrameToReal(frameSize=10000, hopSize = 1)(zeros(1024))
self.assertEqual(len(found), 1)

suite = allTests(TestFrameToReal)

if __name__ == '__main__':
TextTestRunner(verbosity=2).run(suite)
41 changes: 41 additions & 0 deletions test/src/unittests/streaming/test_tensortovectorreal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

# Copyright (C) 2006-2021 Music Technology Group - Universitat Pompeu Fabra
#
# This file is part of Essentia
#
# Essentia is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the Affero GNU General Public License
# version 3 along with this program. If not, see http://www.gnu.org/licenses/


from essentia_test import *
from essentia.streaming import *


class TestTensorToVectorReal(TestCase):

def testInvalidParam(self):
self.assertConfigureFails(VectorRealToTensor(), {'shape': [1, 2, 1, 1]})
self.assertConfigureFails(VectorRealToTensor(), {'batchHopSize': -1})
self.assertConfigureFails(VectorRealToTensor(), {'lastPatchMode': 'invalidstring'})
self.assertConfigureFails(VectorRealToTensor(), {'patchHopSize': -1})
self.assertConfigureFails(VectorRealToTensor(), {'shape': [0, 1, 1, 1]})
self.assertConfigureFails(VectorRealToTensor(), {'shape': [1, 0, 1, 1]})
self.assertConfigureFails(VectorRealToTensor(), {'shape': [1, 1, 0, 1]})
self.assertConfigureFails(VectorRealToTensor(), {'shape': [1, 1, 0, 0]})


suite = allTests(TestTensorToVectorReal)

if __name__ == '__main__':
TextTestRunner(verbosity=2).run(suite)