changeset 84:d91a2285fbb2

naming: local variables snake_case
author Chris Cannam
date Wed, 21 Jan 2015 13:04:01 +0000
parents fbd084b81ece
children 02956a88ee58
files vamp/collect.py vamp/frames.py vamp/load.py vamp/process.py
diffstat 4 files changed, 43 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/vamp/collect.py	Wed Jan 21 12:46:33 2015 +0000
+++ b/vamp/collect.py	Wed Jan 21 13:04:01 2015 +0000
@@ -18,13 +18,13 @@
 ##
 ##!!!
 
-# def timestampFeatures(sampleRate, stepSize, outputDescriptor, features):
+# def timestampFeatures(sample_rate, step_size, outputDescriptor, features):
 
 #     n = 0
     
 #     if outputDict.sampleType == vampyhost.ONE_SAMPLE_PER_STEP:
 #         for True:
-#             yield vampyhost.frame_to_realtime(n * stepSize, sampleRate)
+#             yield vampyhost.frame_to_realtime(n * step_size, sample_rate)
 #             n = n + 1
 
 #     elif outputDict.sampleType == vampyhost.FIXED_SAMPLE_RATE:
@@ -32,23 +32,23 @@
             
 
 
-def collect(data, sampleRate, key, parameters = {}, output = ""):
+def collect(data, sample_rate, key, parameters = {}, output = ""):
     
-    plug, stepSize, blockSize = load.load_and_configure(data, sampleRate, key, parameters)
+    plug, step_size, block_size = load.load_and_configure(data, sample_rate, key, parameters)
 
-    plugOuts = plug.get_outputs()
-    if plugOuts == []:
+    plug_outs = plug.get_outputs()
+    if plug_outs == []:
         return
 
     outNo = -1
-    for n, o in zip(range(0, len(plugOuts)), plugOuts):
+    for n, o in zip(range(0, len(plug_outs)), plug_outs):
         if output == "" or o["identifier"] == output:
             outNo = n
             break
 
     assert outNo >= 0 #!!! todo proper error reporting
 
-    ff = frames.frames_from_array(data, stepSize, blockSize)
+    ff = frames.frames_from_array(data, step_size, block_size)
     fi = 0
 
     #!!! todo!
--- a/vamp/frames.py	Wed Jan 21 12:46:33 2015 +0000
+++ b/vamp/frames.py	Wed Jan 21 13:04:01 2015 +0000
@@ -2,10 +2,10 @@
 
 import numpy
 
-def frames_from_array(arr, stepSize, frameSize):
-    """Generate a list of frames of size frameSize, extracted from the input array arr at stepSize intervals"""
+def frames_from_array(arr, step_size, frameSize):
+    """Generate a list of frames of size frameSize, extracted from the input array arr at step_size intervals"""
     # presumably such a function exists in many places, but I need practice
-    assert(stepSize > 0)
+    assert(step_size > 0)
     if arr.ndim == 1: # turn 1d into 2d array with 1 channel
         arr = numpy.reshape(arr, (1, arr.shape[0]))
     assert(arr.ndim == 2)
@@ -18,5 +18,5 @@
             pad = numpy.zeros((frame.shape[0], frameSize - w))
             frame = numpy.concatenate((frame, pad), 1)
         yield frame
-        i = i + stepSize
+        i = i + step_size
 
--- a/vamp/load.py	Wed Jan 21 12:46:33 2015 +0000
+++ b/vamp/load.py	Wed Jan 21 13:04:01 2015 +0000
@@ -5,26 +5,26 @@
 def list_plugins():
     return vampyhost.list_plugins()
 
-def load_and_configure(data, sampleRate, key, parameters):
+def load_and_configure(data, sample_rate, key, parameters):
 
-    plug = vampyhost.load_plugin(key, sampleRate,
+    plug = vampyhost.load_plugin(key, sample_rate,
                                  vampyhost.ADAPT_INPUT_DOMAIN +
                                  vampyhost.ADAPT_CHANNEL_COUNT)
 
     plug.set_parameter_values(parameters)
 
-    stepSize = plug.get_preferred_step_size()
-    blockSize = plug.get_preferred_block_size()
+    step_size = plug.get_preferred_step_size()
+    block_size = plug.get_preferred_block_size()
 
-    if blockSize == 0:
-        blockSize = 1024
-    if stepSize == 0:
-        stepSize = blockSize ##!!! or blockSize/2, but check this with input domain adapter
+    if block_size == 0:
+        block_size = 1024
+    if step_size == 0:
+        step_size = block_size ##!!! or block_size/2, but check this with input domain adapter
 
     channels = 1
     if data.ndim > 1:
         channels = data.shape[0]
 
-    plug.initialise(channels, stepSize, blockSize)
-    return (plug, stepSize, blockSize)
+    plug.initialise(channels, step_size, block_size)
+    return (plug, step_size, block_size)
 
--- a/vamp/process.py	Wed Jan 21 12:46:33 2015 +0000
+++ b/vamp/process.py	Wed Jan 21 13:04:01 2015 +0000
@@ -4,65 +4,65 @@
 import frames
 import load
 
-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 load_and_query(data, sample_rate, key, parameters):
+    plug, step_size, block_size = load.load_and_configure(data, sample_rate, key, parameters)
+    plug_outs = plug.get_outputs()
+    out_indices = dict(zip([o["identifier"] for o in plug_outs],
+                          range(0, len(plug_outs))))  # id -> n
+    return plug, step_size, block_size, out_indices
     
 
-def process_multiple_outputs(data, sampleRate, key, outputs, parameters = {}):
+def process_multiple_outputs(data, sample_rate, key, outputs, parameters = {}):
 #!!! docstring
 
-    plug, stepSize, blockSize, outIndices = load_and_query(data, sampleRate, key, parameters)
+    plug, step_size, block_size, out_indices = load_and_query(data, sample_rate, key, parameters)
 
     for o in outputs:
-        assert o in outIndices
+        assert o in out_indices
 
-    ff = frames.frames_from_array(data, stepSize, blockSize)
+    ff = frames.frames_from_array(data, step_size, block_size)
     fi = 0
 
     for f in ff:
-        results = plug.process_block(f, vampyhost.frame_to_realtime(fi, sampleRate))
+        results = plug.process_block(f, vampyhost.frame_to_realtime(fi, sample_rate))
         # results is a dict mapping output number -> list of feature dicts
         for o in outputs:
-            outix = outIndices[o]
+            outix = out_indices[o]
             if outix in results:
                 for r in results[outix]:
                     yield { o: r }
-        fi = fi + stepSize
+        fi = fi + step_size
 
     results = plug.get_remaining_features()
     for o in outputs:
-        outix = outIndices[o]
+        outix = out_indices[o]
         if outix in results:
             for r in results[outix]:
                 yield { o: r }
 
     plug.unload()
 
-def process(data, sampleRate, key, output = "", parameters = {}):
+def process(data, sample_rate, key, output = "", parameters = {}):
 #!!! docstring
 
-    plug, stepSize, blockSize, outIndices = load_and_query(data, sampleRate, key, parameters)
+    plug, step_size, block_size, out_indices = load_and_query(data, sample_rate, key, parameters)
 
     if output == "":
         outix = 0
     else:
-        assert output in outIndices
-        outix = outIndices[output]
+        assert output in out_indices
+        outix = out_indices[output]
     
-    ff = frames.frames_from_array(data, stepSize, blockSize)
+    ff = frames.frames_from_array(data, step_size, block_size)
     fi = 0
 
     for f in ff:
-        results = plug.process_block(f, vampyhost.frame_to_realtime(fi, sampleRate))
+        results = plug.process_block(f, vampyhost.frame_to_realtime(fi, sample_rate))
         # results is a dict mapping output number -> list of feature dicts
         if outix in results:
             for r in results[outix]:
                 yield r
-        fi = fi + stepSize
+        fi = fi + step_size
 
     results = plug.get_remaining_features()
     if outix in results: