changeset 79:650f0697812f

naming: vampyhost module methods snake_case
author Chris Cannam
date Wed, 21 Jan 2015 12:28:16 +0000
parents f61ca3c81272
children de501b7e165a
files native/vampyhost.cpp test/test_metadata.py test/test_plugin_metadata.py test/test_processBlock.py vamp/__init__.py vamp/collect.py vamp/load.py vamp/process.py
diffstat 8 files changed, 53 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/native/vampyhost.cpp	Wed Jan 21 12:23:34 2015 +0000
+++ b/native/vampyhost.cpp	Wed Jan 21 12:28:16 2015 +0000
@@ -64,7 +64,7 @@
 using namespace Vamp::HostExt;
 
 static PyObject *
-enumeratePlugins(PyObject *self, PyObject *)
+list_plugins(PyObject *self, PyObject *)
 {
     PluginLoader *loader = PluginLoader::getInstance();
     vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
@@ -73,7 +73,7 @@
 }
 
 static PyObject *
-getPluginPath(PyObject *self, PyObject *)
+get_plugin_path(PyObject *self, PyObject *)
 {
     vector<string> path = PluginHostAdapter::getPluginPath();
     VectorConversion conv;
@@ -97,13 +97,13 @@
 }
 
 static PyObject *
-getLibraryFor(PyObject *self, PyObject *args)
+get_library_for(PyObject *self, PyObject *args)
 {
     PyObject *pyPluginKey;
 
     if (!PyArg_ParseTuple(args, "S", &pyPluginKey)) {
         PyErr_SetString(PyExc_TypeError,
-                        "getLibraryPathForPlugin() takes plugin key (string) argument");
+                        "get_library_for() takes plugin key (string) argument");
         return 0; }
 
     string pluginKey = toPluginKey(pyPluginKey);
@@ -116,13 +116,13 @@
 }
 
 static PyObject *
-getPluginCategory(PyObject *self, PyObject *args)
+get_category_of(PyObject *self, PyObject *args)
 {
     PyObject *pyPluginKey;
 
     if (!PyArg_ParseTuple(args, "S", &pyPluginKey)) {
         PyErr_SetString(PyExc_TypeError,
-                        "getPluginCategory() takes plugin key (string) argument");
+                        "get_category_of() takes plugin key (string) argument");
         return 0; }
 
     string pluginKey = toPluginKey(pyPluginKey);
@@ -137,13 +137,13 @@
 }
 
 static PyObject *
-getOutputList(PyObject *self, PyObject *args)
+get_outputs_of(PyObject *self, PyObject *args)
 {
     PyObject *pyPluginKey;
 
     if (!PyArg_ParseTuple(args, "S", &pyPluginKey)) {
         PyErr_SetString(PyExc_TypeError,
-                        "getOutputList() takes plugin key (string) argument");
+                        "get_outputs_of() takes plugin key (string) argument");
         return 0; }
 
     Plugin::OutputList outputs;
@@ -174,7 +174,7 @@
 }
 
 static PyObject *
-loadPlugin(PyObject *self, PyObject *args)
+load_plugin(PyObject *self, PyObject *args)
 {
     PyObject *pyPluginKey;
     float inputSampleRate;
@@ -185,7 +185,7 @@
                           &inputSampleRate,
                           &adapterFlags)) {
         PyErr_SetString(PyExc_TypeError,
-                        "loadPlugin() takes plugin key (string), sample rate (float), and adapter flags (int) arguments");
+                        "load_plugin() takes plugin key (string), sample rate (float), and adapter flags (int) arguments");
         return 0; }
 
     string pluginKey = toPluginKey(pyPluginKey);
@@ -206,7 +206,7 @@
 }
 
 static PyObject *
-frame2RealTime(PyObject *self, PyObject *args)
+frame_to_realtime(PyObject *self, PyObject *args)
 {
     int frame;
     int rate;
@@ -215,7 +215,7 @@
                           &frame,
                           &rate)) {
         PyErr_SetString(PyExc_TypeError,
-                        "frame2RealTime() takes frame (int) and sample rate (int) arguments");
+                        "frame_to_realtime() takes frame (int) and sample rate (int) arguments");
         return 0; }
 
     RealTime rt = RealTime::frame2RealTime(frame, rate);
@@ -225,26 +225,26 @@
 // module methods table
 static PyMethodDef vampyhost_methods[] = {
     
-    {"listPlugins", enumeratePlugins, METH_NOARGS,
-     "listPlugins() -> Return a list of the plugin keys of all installed Vamp plugins." },
+    {"list_plugins", list_plugins, METH_NOARGS,
+     "list_plugins() -> Return a list of the plugin keys of all installed Vamp plugins." },
 
-    {"getPluginPath", getPluginPath, METH_NOARGS,
-     "getPluginPath() -> Return a list of directories which will be searched for Vamp plugins. This may be changed by setting the VAMP_PATH environment variable."},
+    {"get_plugin_path", get_plugin_path, METH_NOARGS,
+     "get_plugin_path() -> Return a list of directories which will be searched for Vamp plugins. This may be changed by setting the VAMP_PATH environment variable."},
 
-    {"getCategoryOf", getPluginCategory, METH_VARARGS,
-     "getCategoryOf(pluginKey) -> Return the category of a Vamp plugin given its key, if known. The category is expressed as a list of nested types from least to most specific."},
+    {"get_category_of", get_category_of, METH_VARARGS,
+     "get_category_of(pluginKey) -> Return the category of a Vamp plugin given its key, if known. The category is expressed as a list of nested types from least to most specific."},
 
-    {"getLibraryFor", getLibraryFor, METH_VARARGS,
-     "getLibraryFor(pluginKey) -> Return the file path of the Vamp plugin library in which the given plugin key is found, or an empty string if the plugin is not installed."},
+    {"get_library_for", get_library_for, METH_VARARGS,
+     "get_library_for(pluginKey) -> Return the file path of the Vamp plugin library in which the given plugin key is found, or an empty string if the plugin is not installed."},
 
-    {"getOutputsOf", getOutputList, METH_VARARGS,
-     "getOutputsOf(pluginKey) -> Return a list of the output identifiers of the plugin with the given key, if installed."},
+    {"get_outputs_of", get_outputs_of, METH_VARARGS,
+     "get_outputs_of(pluginKey) -> Return a list of the output identifiers of the plugin with the given key, if installed."},
 
-    {"loadPlugin", loadPlugin, METH_VARARGS,
-     "loadPlugin(pluginKey, samplerate) -> Load the plugin that has the given key, if installed, and return the plugin object."},
+    {"load_plugin", load_plugin, METH_VARARGS,
+     "load_plugin(pluginKey, samplerate) -> Load the plugin that has the given key, if installed, and return the plugin object."},
 
-    {"frame2RealTime", frame2RealTime, METH_VARARGS,
-     "frame2RealTime() -> Convert sample frame number and sample rate to a RealTime object." },
+    {"frame_to_realtime", frame_to_realtime, METH_VARARGS,
+     "frame_to_realtime() -> Convert sample frame number and sample rate to a RealTime object." },
 
     {0, 0}              /* sentinel */
 };
--- a/test/test_metadata.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/test/test_metadata.py	Wed Jan 21 12:28:16 2015 +0000
@@ -6,23 +6,23 @@
 ##!!! could use: plugin version
 
 def test_list():
-    plugins = vh.listPlugins()
+    plugins = vh.list_plugins()
     if testPluginKey not in plugins:
         print("Test plugin " + testPluginKey + " not installed or not returned by enumerate: can't run any tests without it")
     assert testPluginKey in plugins
 
 def test_path():
-    path = vh.getPluginPath()
+    path = vh.get_plugin_path()
     assert len(path) > 0
 
 def test_getlibrary():
-    lib = vh.getLibraryFor(testPluginKey)
+    lib = vh.get_library_for(testPluginKey)
     assert lib.find("vamp-test-plugin") >= 0
     try:
-        lib = vh.getLibraryFor("not a well-formatted plugin key")
+        lib = vh.get_library_for("not a well-formatted plugin key")
         assert False
     except TypeError:
         pass
-    lib = vh.getLibraryFor("nonexistent-library:nonexistent-plugin")
+    lib = vh.get_library_for("nonexistent-library:nonexistent-plugin")
     assert lib == ""
     
--- a/test/test_plugin_metadata.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/test/test_plugin_metadata.py	Wed Jan 21 12:28:16 2015 +0000
@@ -10,35 +10,35 @@
 expectedVersion = 3
 
 def test_plugin_exists():
-    assert testPluginKey in vh.listPlugins()
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    assert testPluginKey in vh.list_plugins()
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     assert "pluginVersion" in plug.info
     if plug.info["pluginVersion"] != expectedVersion:
         print("Test plugin version " + str(plug.info["pluginVersion"]) + " does not match expected version " + str(expectedVersion))
     assert plug.info["pluginVersion"] == expectedVersion
 
 def test_plugin_exists_in_freq_version():
-    assert testPluginKeyFreq in vh.listPlugins()
+    assert testPluginKeyFreq in vh.list_plugins()
 
 def test_getoutputlist():
-    outputs = vh.getOutputsOf(testPluginKey)
+    outputs = vh.get_outputs_of(testPluginKey)
     assert len(outputs) == 10
     assert "input-summary" in outputs
 
 def test_inputdomain():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     assert plug.inputDomain == vh.TIME_DOMAIN
 
 def test_info():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     assert plug.info["identifier"] == "vamp-test-plugin"
     
 def test_parameterdescriptors():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     assert plug.parameters[0]["identifier"] == "produce_output"
     
 def test_setparameter():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     assert plug.parameters[0]["identifier"] == "produce_output"
     assert plug.parameters[0]["defaultValue"] == 1
     assert plug.getParameterValue("produce_output") == plug.parameters[0]["defaultValue"]
--- a/test/test_processBlock.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/test/test_processBlock.py	Wed Jan 21 12:28:16 2015 +0000
@@ -7,7 +7,7 @@
 rate = 44100
 
 def test_load_unload():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     plug.unload()
     try:
         plug.unload() # should throw but not crash
@@ -16,7 +16,7 @@
         pass
 
 def test_get_set_parameter():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     value = plug.getParameterValue("produce_output")
     assert(value == 1.0)
     plug.setParameterValue("produce_output", 0.0)
@@ -24,7 +24,7 @@
     assert(value == 0.0)
     
 def test_process_without_initialise():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     try:
         plug.processBlock([[1,2,3,4]], vh.RealTime(0, 0))
         assert False
@@ -32,7 +32,7 @@
         pass
 
 def test_process_input_format():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     plug.initialise(2, 4, 4) # channels, stepsize, blocksize
     result = plug.processBlock([[1,2,3,4],[5,6,7,8]], vh.RealTime(0, 0))
     result = plug.processBlock([np.array([1,2,3,4]),np.array([5,6,7,8])], vh.RealTime(0, 0))
@@ -57,7 +57,7 @@
         pass
 
 def test_process_output_1ch():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     plug.initialise(1, 2, 2)
     try:
         # Too many channels
@@ -71,7 +71,7 @@
     assert result[8] == [ { "label" : "", "values" : np.array([4.0]) } ]
 
 def test_process_output_2ch():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     plug.initialise(2, 2, 2)
     try:
         # Too few channels
@@ -91,7 +91,7 @@
     assert (result[8][0]["values"] == np.array([4.0,5.0])).all()
 
 def test_process_output_3ch():
-    plug = vh.loadPlugin(testPluginKey, rate, vh.ADAPT_NONE)
+    plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE)
     plug.initialise(3, 2, 2)
     try:
         # Too few channels
--- a/vamp/__init__.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/vamp/__init__.py	Wed Jan 21 12:28:16 2015 +0000
@@ -2,7 +2,7 @@
 
 import vampyhost
 
-from load import listPlugins, loadAndConfigureFor
+from load import list_plugins, loadAndConfigureFor
 from frames import framesFromArray
 from process import process, processMultipleOutputs
 from collect import collect
--- a/vamp/collect.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/vamp/collect.py	Wed Jan 21 12:28:16 2015 +0000
@@ -24,7 +24,7 @@
     
 #     if outputDict.sampleType == vampyhost.ONE_SAMPLE_PER_STEP:
 #         for True:
-#             yield vampyhost.frame2RealTime(n * stepSize, sampleRate)
+#             yield vampyhost.frame_to_realtime(n * stepSize, sampleRate)
 #             n = n + 1
 
 #     elif outputDict.sampleType == vampyhost.FIXED_SAMPLE_RATE:
--- a/vamp/load.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/vamp/load.py	Wed Jan 21 12:28:16 2015 +0000
@@ -2,11 +2,11 @@
 
 import vampyhost
 
-def listPlugins():
-    return vampyhost.listPlugins()
+def list_plugins():
+    return vampyhost.list_plugins()
 
 def loadAndConfigureFor(data, sampleRate, key, parameters):
-    plug = vampyhost.loadPlugin(key, sampleRate,
+    plug = vampyhost.load_plugin(key, sampleRate,
                                 vampyhost.ADAPT_INPUT_DOMAIN +
                                 vampyhost.ADAPT_CHANNEL_COUNT)
 
--- a/vamp/process.py	Wed Jan 21 12:23:34 2015 +0000
+++ b/vamp/process.py	Wed Jan 21 12:28:16 2015 +0000
@@ -24,7 +24,7 @@
     fi = 0
 
     for f in ff:
-        results = plug.processBlock(f, vampyhost.frame2RealTime(fi, sampleRate))
+        results = plug.processBlock(f, vampyhost.frame_to_realtime(fi, sampleRate))
         # results is a dict mapping output number -> list of feature dicts
         for o in outputs:
             outix = outIndices[o]
@@ -57,7 +57,7 @@
     fi = 0
 
     for f in ff:
-        results = plug.processBlock(f, vampyhost.frame2RealTime(fi, sampleRate))
+        results = plug.processBlock(f, vampyhost.frame_to_realtime(fi, sampleRate))
         # results is a dict mapping output number -> list of feature dicts
         if outix in results:
             for r in results[outix]: