# HG changeset patch # User Chris Cannam # Date 1421844230 0 # Node ID a11b57e9fb0be99e605bfe566a7987625a9aec98 # Parent 0a2f2e7803eab40cfeb9584a23ab6139c2db9b8c naming: module methods snake_case diff -r 0a2f2e7803ea -r a11b57e9fb0b native/PyPluginObject.cpp --- a/native/PyPluginObject.cpp Wed Jan 21 12:32:32 2015 +0000 +++ b/native/PyPluginObject.cpp Wed Jan 21 12:43:50 2015 +0000 @@ -109,7 +109,7 @@ (infodict, "copyright", pystr(plugin->getCopyright())); pd->info = infodict; - pd->input_domain = plugin->getInputDomain(); + pd->inputDomain = plugin->getInputDomain(); VectorConversion conv; @@ -617,7 +617,7 @@ {(char *)"info", T_OBJECT, offsetof(PyPluginObject, info), READONLY, (char *)"info -> A read-only dictionary of plugin metadata."}, - {(char *)"input_domain", T_INT, offsetof(PyPluginObject, input_domain), READONLY, + {(char *)"input_domain", T_INT, offsetof(PyPluginObject, inputDomain), READONLY, (char *)"input_domain -> The format of input audio required by the plugin, either vampyhost.TIME_DOMAIN or vampyhost.FREQUENCY_DOMAIN."}, {(char *)"parameters", T_OBJECT, offsetof(PyPluginObject, parameters), READONLY, diff -r 0a2f2e7803ea -r a11b57e9fb0b native/PyRealTime.cpp --- a/native/PyRealTime.cpp Wed Jan 21 12:32:32 2015 +0000 +++ b/native/PyRealTime.cpp Wed Jan 21 12:43:50 2015 +0000 @@ -164,14 +164,14 @@ {"values", (PyCFunction)RealTime_values, METH_NOARGS, PyDoc_STR("values() -> Tuple of sec,nsec representation.")}, - {"toString", (PyCFunction)RealTime_toString, METH_NOARGS, - PyDoc_STR("toString() -> Return a user-readable string to the nearest millisecond in a form like HH:MM:SS.mmm")}, + {"to_string", (PyCFunction)RealTime_toString, METH_NOARGS, + PyDoc_STR("to_string() -> Return a user-readable string to the nearest millisecond in a form like HH:MM:SS.mmm")}, - {"toFrame", (PyCFunction)RealTime_toFrame, METH_VARARGS, - PyDoc_STR("toFrame(samplerate) -> Sample count for given sample rate.")}, + {"to_frame", (PyCFunction)RealTime_toFrame, METH_VARARGS, + PyDoc_STR("to_frame(samplerate) -> Sample count for given sample rate.")}, - {"toFloat", (PyCFunction)RealTime_float, METH_NOARGS, - PyDoc_STR("toFloat() -> Floating point representation.")}, + {"to_float", (PyCFunction)RealTime_float, METH_NOARGS, + PyDoc_STR("to_float() -> Floating point representation.")}, {NULL, NULL} /* sentinel */ }; diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_collect.py --- a/test/test_collect.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_collect.py Wed Jan 21 12:43:50 2015 +0000 @@ -2,8 +2,8 @@ import vamp import numpy as np -testPluginKey = "vamp-test-plugin:vamp-test-plugin" -testPluginKeyFreq = "vamp-test-plugin:vamp-test-plugin-freq" +plugin_key = "vamp-test-plugin:vamp-test-plugin" +plugin_key_freq = "vamp-test-plugin:vamp-test-plugin-freq" rate = 44100 @@ -21,5 +21,5 @@ def test_collect_runs_at_all(): buf = input_data(blocksize) - results = vamp.collect(buf, rate, testPluginKey, {}, "input-summary") + results = vamp.collect(buf, rate, plugin_key, {}, "input-summary") assert type(results) == dict diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_frames.py --- a/test/test_frames.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_frames.py Wed Jan 21 12:43:50 2015 +0000 @@ -7,16 +7,16 @@ def test_frames_from_1d_buffer(): buf = np.arange(6) - ff = to_lists(vamp.framesFromArray(buf, 2, 2)) + ff = to_lists(vamp.frames_from_array(buf, 2, 2)) assert(ff == [[[0,1]],[[2,3]],[[4,5]]]) - ff = to_lists(vamp.framesFromArray(buf, 1, 2)) + ff = to_lists(vamp.frames_from_array(buf, 1, 2)) assert(ff == [[[0,1]],[[1,2]],[[2,3]],[[3,4]],[[4,5]],[[5,0]]]) def test_frames_from_2d_buffer(): buf = np.array([np.arange(6),np.arange(6,12)]) - ff = to_lists(vamp.framesFromArray(buf, 2, 2)) + ff = to_lists(vamp.frames_from_array(buf, 2, 2)) assert(ff == [[[0,1],[6,7]],[[2,3],[8,9]],[[4,5],[10,11]]]) - ff = to_lists(vamp.framesFromArray(buf, 1, 2)) + ff = to_lists(vamp.frames_from_array(buf, 1, 2)) assert(ff == [[[0,1],[6,7]],[[1,2],[7,8]],[[2,3],[8,9]], [[3,4],[9,10]],[[4,5],[10,11]],[[5,0],[11,0]]]) diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_metadata.py --- a/test/test_metadata.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_metadata.py Wed Jan 21 12:43:50 2015 +0000 @@ -1,22 +1,22 @@ import vampyhost as vh -testPluginKey = "vamp-test-plugin:vamp-test-plugin" +plugin_key = "vamp-test-plugin:vamp-test-plugin" ##!!! could use: plugin version def test_list(): 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 + if plugin_key not in plugins: + print("Test plugin " + plugin_key + " not installed or not returned by enumerate: can't run any tests without it") + assert plugin_key in plugins def test_path(): path = vh.get_plugin_path() assert len(path) > 0 def test_getlibrary(): - lib = vh.get_library_for(testPluginKey) + lib = vh.get_library_for(plugin_key) assert lib.find("vamp-test-plugin") >= 0 try: lib = vh.get_library_for("not a well-formatted plugin key") diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_plugin_metadata.py --- a/test/test_plugin_metadata.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_plugin_metadata.py Wed Jan 21 12:43:50 2015 +0000 @@ -1,44 +1,44 @@ import vampyhost as vh -testPluginKey = "vamp-test-plugin:vamp-test-plugin" +plugin_key = "vamp-test-plugin:vamp-test-plugin" -testPluginKeyFreq = "vamp-test-plugin:vamp-test-plugin-freq" +plugin_key_freq = "vamp-test-plugin:vamp-test-plugin-freq" rate = 44100 expectedVersion = 3 def test_plugin_exists(): - assert testPluginKey in vh.list_plugins() - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + assert plugin_key in vh.list_plugins() + plug = vh.load_plugin(plugin_key, 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.list_plugins() + assert plugin_key_freq in vh.list_plugins() def test_getoutputlist(): - outputs = vh.get_outputs_of(testPluginKey) + outputs = vh.get_outputs_of(plugin_key) assert len(outputs) == 10 assert "input-summary" in outputs def test_inputdomain(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) assert plug.input_domain == vh.TIME_DOMAIN def test_info(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) assert plug.info["identifier"] == "vamp-test-plugin" def test_parameterdescriptors(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) assert plug.parameters[0]["identifier"] == "produce_output" def test_setparameter(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) assert plug.parameters[0]["identifier"] == "produce_output" assert plug.parameters[0]["defaultValue"] == 1 assert plug.get_parameter_value("produce_output") == plug.parameters[0]["defaultValue"] diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_process.py --- a/test/test_process.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_process.py Wed Jan 21 12:43:50 2015 +0000 @@ -2,8 +2,8 @@ import vamp import numpy as np -testPluginKey = "vamp-test-plugin:vamp-test-plugin" -testPluginKeyFreq = "vamp-test-plugin:vamp-test-plugin-freq" +plugin_key = "vamp-test-plugin:vamp-test-plugin" +plugin_key_freq = "vamp-test-plugin:vamp-test-plugin-freq" rate = 44100 @@ -21,18 +21,18 @@ def test_process_n(): buf = input_data(blocksize) - results = list(vamp.process(buf, rate, testPluginKey, "input-summary")) + results = list(vamp.process(buf, rate, plugin_key, "input-summary")) assert len(results) == 1 def test_process_freq_n(): buf = input_data(blocksize) - results = list(vamp.process(buf, rate, testPluginKeyFreq, "input-summary", {})) + results = list(vamp.process(buf, rate, plugin_key_freq, "input-summary", {})) assert len(results) == 2 # one complete block starting at zero, one half-full def test_process_default_output(): # If no output is specified, we should get the first one (instants) buf = input_data(blocksize) - results = list(vamp.process(buf, rate, testPluginKey, "", {})) + results = list(vamp.process(buf, rate, plugin_key, "", {})) assert len(results) == 10 for i in range(len(results)): expectedTime = vamp.vampyhost.RealTime('seconds', i * 1.5) @@ -41,27 +41,27 @@ def test_process_summary_param(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKey, "input-summary", { "produce_output": 0 })) + results = list(vamp.process(buf, rate, plugin_key, "input-summary", { "produce_output": 0 })) assert len(results) == 0 def test_process_multi_summary_param(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKey, [ "input-summary" ], { "produce_output": 0 })) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key, [ "input-summary" ], { "produce_output": 0 })) assert len(results) == 0 def test_process_summary_param_bool(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKey, "input-summary", { "produce_output": False })) + results = list(vamp.process(buf, rate, plugin_key, "input-summary", { "produce_output": False })) assert len(results) == 0 def test_process_multi_summary_param_bool(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKey, [ "input-summary" ], { "produce_output": False })) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key, [ "input-summary" ], { "produce_output": False })) assert len(results) == 0 def test_process_summary(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKey, "input-summary", {})) + results = list(vamp.process(buf, rate, plugin_key, "input-summary", {})) assert len(results) == 10 for i in range(len(results)): # @@ -75,7 +75,7 @@ def test_process_multi_summary(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKey, [ "input-summary" ], {})) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key, [ "input-summary" ], {})) assert len(results) == 10 for i in range(len(results)): # @@ -89,7 +89,7 @@ def test_process_freq_summary(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKeyFreq, "input-summary", {})) + results = list(vamp.process(buf, rate, plugin_key_freq, "input-summary", {})) assert len(results) == 20 for i in range(len(results)): # @@ -127,7 +127,7 @@ def test_process_multi_freq_summary(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKeyFreq, [ "input-summary" ], {})) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key_freq, [ "input-summary" ], {})) assert len(results) == 20 for i in range(len(results)): expected = i * (blocksize/2) + blocksize/2 + 1 # "first" elt @@ -140,7 +140,7 @@ def test_process_timestamps(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKey, "input-timestamp", {})) + results = list(vamp.process(buf, rate, plugin_key, "input-timestamp", {})) assert len(results) == 10 for i in range(len(results)): # The timestamp should be the frame number of the first frame in the @@ -151,7 +151,7 @@ def test_process_multi_timestamps(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKey, [ "input-timestamp" ])) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key, [ "input-timestamp" ])) assert len(results) == 10 for i in range(len(results)): # The timestamp should be the frame number of the first frame in the @@ -162,7 +162,7 @@ def test_process_freq_timestamps(): buf = input_data(blocksize * 10) - results = list(vamp.process(buf, rate, testPluginKeyFreq, "input-timestamp", {})) + results = list(vamp.process(buf, rate, plugin_key_freq, "input-timestamp", {})) assert len(results) == 20 for i in range(len(results)): # The timestamp should be the frame number of the frame just beyond @@ -173,7 +173,7 @@ def test_process_multi_freq_timestamps(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKeyFreq, [ "input-timestamp" ], {})) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key_freq, [ "input-timestamp" ], {})) assert len(results) == 20 for i in range(len(results)): # The timestamp should be the frame number of the frame just beyond @@ -184,7 +184,7 @@ def test_process_multiple_outputs(): buf = input_data(blocksize * 10) - results = list(vamp.processMultipleOutputs(buf, rate, testPluginKey, [ "input-summary", "input-timestamp" ], {})) + results = list(vamp.process_multiple_outputs(buf, rate, plugin_key, [ "input-summary", "input-timestamp" ], {})) assert len(results) == 20 si = 0 ti = 0 diff -r 0a2f2e7803ea -r a11b57e9fb0b test/test_processBlock.py --- a/test/test_processBlock.py Wed Jan 21 12:32:32 2015 +0000 +++ b/test/test_processBlock.py Wed Jan 21 12:43:50 2015 +0000 @@ -2,12 +2,12 @@ import vampyhost as vh import numpy as np -testPluginKey = "vamp-test-plugin:vamp-test-plugin" +plugin_key = "vamp-test-plugin:vamp-test-plugin" rate = 44100 def test_load_unload(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, 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.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) value = plug.get_parameter_value("produce_output") assert(value == 1.0) plug.set_parameter_value("produce_output", 0.0) @@ -24,7 +24,7 @@ assert(value == 0.0) def test_process_without_initialise(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) try: plug.process_block([[1,2,3,4]], vh.RealTime(0, 0)) assert False @@ -32,7 +32,7 @@ pass def test_process_input_format(): - plug = vh.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) plug.initialise(2, 4, 4) # channels, stepsize, blocksize result = plug.process_block([[1,2,3,4],[5,6,7,8]], vh.RealTime(0, 0)) result = plug.process_block([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.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, 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.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, 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.load_plugin(testPluginKey, rate, vh.ADAPT_NONE) + plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) plug.initialise(3, 2, 2) try: # Too few channels diff -r 0a2f2e7803ea -r a11b57e9fb0b vamp/__init__.py --- a/vamp/__init__.py Wed Jan 21 12:32:32 2015 +0000 +++ b/vamp/__init__.py Wed Jan 21 12:43:50 2015 +0000 @@ -2,7 +2,7 @@ import vampyhost -from load import list_plugins, loadAndConfigureFor -from frames import framesFromArray -from process import process, processMultipleOutputs +from load import list_plugins, load_and_configure +from frames import frames_from_array +from process import process, process_multiple_outputs from collect import collect diff -r 0a2f2e7803ea -r a11b57e9fb0b vamp/collect.py --- a/vamp/collect.py Wed Jan 21 12:32:32 2015 +0000 +++ b/vamp/collect.py Wed Jan 21 12:43:50 2015 +0000 @@ -4,7 +4,7 @@ import load import frames -def selectFeaturesForOutput(output, features): +def select_features_for_output(output, features): for ff in features: if output in ff: for f in ff[output]: @@ -34,7 +34,7 @@ def collect(data, sampleRate, key, parameters = {}, output = ""): - plug, stepSize, blockSize = load.loadAndConfigureFor(data, sampleRate, key, parameters) + plug, stepSize, blockSize = load.load_and_configure(data, sampleRate, key, parameters) plugOuts = plug.get_outputs() if plugOuts == []: @@ -48,7 +48,7 @@ assert outNo >= 0 #!!! todo proper error reporting - ff = frames.framesFromArray(data, stepSize, blockSize) + ff = frames.frames_from_array(data, stepSize, blockSize) fi = 0 #!!! todo! diff -r 0a2f2e7803ea -r a11b57e9fb0b vamp/frames.py --- a/vamp/frames.py Wed Jan 21 12:32:32 2015 +0000 +++ b/vamp/frames.py Wed Jan 21 12:43:50 2015 +0000 @@ -2,7 +2,7 @@ import numpy -def framesFromArray(arr, stepSize, frameSize): +def frames_from_array(arr, stepSize, frameSize): """Generate a list of frames of size frameSize, extracted from the input array arr at stepSize intervals""" # presumably such a function exists in many places, but I need practice assert(stepSize > 0) diff -r 0a2f2e7803ea -r a11b57e9fb0b vamp/load.py --- a/vamp/load.py Wed Jan 21 12:32:32 2015 +0000 +++ b/vamp/load.py Wed Jan 21 12:43:50 2015 +0000 @@ -5,10 +5,11 @@ def list_plugins(): return vampyhost.list_plugins() -def loadAndConfigureFor(data, sampleRate, key, parameters): +def load_and_configure(data, sampleRate, key, parameters): + plug = vampyhost.load_plugin(key, sampleRate, - vampyhost.ADAPT_INPUT_DOMAIN + - vampyhost.ADAPT_CHANNEL_COUNT) + vampyhost.ADAPT_INPUT_DOMAIN + + vampyhost.ADAPT_CHANNEL_COUNT) plug.set_parameter_values(parameters) diff -r 0a2f2e7803ea -r a11b57e9fb0b vamp/process.py --- a/vamp/process.py Wed Jan 21 12:32:32 2015 +0000 +++ b/vamp/process.py Wed Jan 21 12:43:50 2015 +0000 @@ -4,23 +4,23 @@ import frames import load -def loadAndQuery(data, sampleRate, key, parameters): - plug, stepSize, blockSize = load.loadAndConfigureFor(data, sampleRate, key, parameters) +def load_and_query(data, sampleRate, key, parameters): + plug, stepSize, blockSize = load.load_and_configure(data, sampleRate, key, parameters) plugOuts = plug.get_outputs() outIndices = dict(zip([o["identifier"] for o in plugOuts], range(0, len(plugOuts)))) # id -> n return plug, stepSize, blockSize, outIndices -def processMultipleOutputs(data, sampleRate, key, outputs, parameters = {}): +def process_multiple_outputs(data, sampleRate, key, outputs, parameters = {}): #!!! docstring - plug, stepSize, blockSize, outIndices = loadAndQuery(data, sampleRate, key, parameters) + plug, stepSize, blockSize, outIndices = load_and_query(data, sampleRate, key, parameters) for o in outputs: assert o in outIndices - ff = frames.framesFromArray(data, stepSize, blockSize) + ff = frames.frames_from_array(data, stepSize, blockSize) fi = 0 for f in ff: @@ -45,7 +45,7 @@ def process(data, sampleRate, key, output = "", parameters = {}): #!!! docstring - plug, stepSize, blockSize, outIndices = loadAndQuery(data, sampleRate, key, parameters) + plug, stepSize, blockSize, outIndices = load_and_query(data, sampleRate, key, parameters) if output == "": outix = 0 @@ -53,7 +53,7 @@ assert output in outIndices outix = outIndices[output] - ff = frames.framesFromArray(data, stepSize, blockSize) + ff = frames.frames_from_array(data, stepSize, blockSize) fi = 0 for f in ff: