changeset 70:ffdeb8808fc1

Let's favour consistent shape in output, and return the output identifier always
author Chris Cannam
date Wed, 14 Jan 2015 17:19:04 +0000
parents b34d3b58da98
children cb0380c92c42
files Makefile.inc test/test_process.py vamp/__init__.py
diffstat 3 files changed, 9 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.inc	Wed Jan 14 14:53:15 2015 +0000
+++ b/Makefile.inc	Wed Jan 14 17:19:04 2015 +0000
@@ -8,6 +8,8 @@
 
 HEADERS		:= $(SRC_DIR)/PyPluginObject.h $(SRC_DIR)/PyRealTime.h $(SRC_DIR)/FloatConversion.h $(SRC_DIR)/VectorConversion.h
 SOURCES		:= $(SRC_DIR)/PyPluginObject.cpp $(SRC_DIR)/PyRealTime.cpp $(SRC_DIR)/VectorConversion.cpp $(SRC_DIR)/vampyhost.cpp
+
+PY		:= $(wildcard vamp/*.py)
 TESTS		:= $(wildcard test/test_*.py)
 
 OBJECTS		:= $(SOURCES:.cpp=.o)
@@ -18,7 +20,7 @@
 $(LIBRARY):	$(OBJECTS)
 		$(CXX) -o $@ $^ $(LDFLAGS)
 
-.tests:		$(LIBRARY) $(TESTS)
+.tests:		$(LIBRARY) $(PY) $(TESTS)
 		$(NOSE)
 		@touch $@
 
--- a/test/test_process.py	Wed Jan 14 14:53:15 2015 +0000
+++ b/test/test_process.py	Wed Jan 14 17:19:04 2015 +0000
@@ -50,7 +50,7 @@
         # the first elt (which is i * blockSize + 1)
         #
         expected = blocksize + i * blocksize + 1
-        actual = results[i]["values"][0]
+        actual = results[i]["input-summary"]["values"][0]
         assert actual == expected
 
 def test_process_freq_summary():
@@ -87,7 +87,7 @@
         if (i == len(results)-1):
             expected = 0
         expected = expected + blocksize - 1              # non-zero elts
-        actual = results[i]["values"][0]
+        actual = results[i]["input-summary"]["values"][0]
         eps = 1e-6
         assert abs(actual - expected) < eps
 
@@ -99,7 +99,7 @@
         # The timestamp should be the frame number of the first frame in the
         # input buffer
         expected = i * blocksize
-        actual = results[i]["values"][0]
+        actual = results[i]["input-timestamp"]["values"][0]
         assert actual == expected
 
 def test_process_freq_timestamps():
@@ -110,6 +110,6 @@
         # The timestamp should be the frame number of the frame just beyond
         # half-way through the input buffer
         expected = i * (blocksize/2) + blocksize/2
-        actual = results[i]["values"][0]
+        actual = results[i]["input-timestamp"]["values"][0]
         print("actual = " + str(actual) + ", expected = " + str(expected))
         assert actual == expected
--- a/vamp/__init__.py	Wed Jan 14 14:53:15 2015 +0000
+++ b/vamp/__init__.py	Wed Jan 14 17:19:04 2015 +0000
@@ -68,8 +68,6 @@
     if outputs == []:
         outputs = [plugOuts[0]["identifier"]]
 
-    singleOutput = (len(outputs) == 1)
-
     ff = framesFromArray(data, stepSize, blockSize)
     fi = 0
 
@@ -79,20 +77,14 @@
         for o in outputs:
             if outIndices[o] in results:
                 for r in results[outIndices[o]]:
-                    if singleOutput:
-                        yield r
-                    else:
-                        yield { o: r }
+                    yield { o: r }
         fi = fi + stepSize
 
     results = plug.getRemainingFeatures()
     for o in outputs:
         if outIndices[o] in results:
             for r in results[outIndices[o]]:
-                if singleOutput:
-                    yield r
-                else:
-                    yield { o: r }
+                yield { o: r }
 
     plug.unload()