History

[python] add docstrings to alpha_norm and zero_crossing_rate

Paul Brossier committed 8 years ago

Commit 55b62601 parent 7df8df71 file · +59 −9Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/aubiomodule.c+59−9
@@ -10,14 +10,37 @@ · 9 unmodified lines
1010 static char aubio_module_doc[] = "Python module for the aubio library";
1111
1212 static char Py_alpha_norm_doc[] = ""
13−"alpha_norm(fvec, integer) -> float\n"
13+"alpha_norm(vec, alpha)\n"
1414 "\n"
15−"Compute alpha normalisation factor on vector, given alpha\n"
15+"Compute `alpha` normalisation factor of vector `vec`.\n"
16+"\n"
17+"Parameters\n"
18+"----------\n"
19+"vec : fvec\n"
20+" input vector\n"
21+"alpha : float\n"
22+" norm factor\n"
23+"\n"
24+"Returns\n"
25+"-------\n"
26+"float\n"
27+" p-norm of the input vector, where `p=alpha`\n"
1628 "\n"
1729 "Example\n"
1830 "-------\n"
1931 "\n"
20−">>> b = alpha_norm(a, 9)";
32+">>> a = aubio.fvec(np.arange(10)); alpha = 2\n"
33+">>> aubio.alpha_norm(a, alpha), (sum(a**alpha)/len(a))**(1./alpha)\n"
34+"(5.338539123535156, 5.338539126015656)\n"
35+"\n"
36+"Note\n"
37+"----\n"
38+"Computed as:\n"
39+"\n"
40+".. math::\n"
41+" l_{\\alpha} = \n"
42+" \\|\\frac{\\sum_{n=0}^{N-1}{{x_n}^{\\alpha}}}{N}\\|^{1/\\alpha}\n"
43+"";
2144
2245 static char Py_bintomidi_doc[] = ""
2346 "bintomidi(fftbin, samplerate, fftsize)\n"
@@ -130,24 +153,51 @@ static char Py_freqtobin_doc[] = "" · 106 unmodified lines
130153 "";
131154
132155 static char Py_zero_crossing_rate_doc[] = ""
133−"zero_crossing_rate(fvec) -> float\n"
156+"zero_crossing_rate(vec)\n"
157+"\n"
158+"Compute zero-crossing rate of `vec`.\n"
159+"\n"
160+"Parameters\n"
161+"----------\n"
162+"vec : fvec\n"
163+" input vector\n"
134164 "\n"
135−"Compute Zero crossing rate of a vector\n"
165+"Returns\n"
166+"-------\n"
167+"float\n"
168+" Zero-crossing rate.\n"
136169 "\n"
137170 "Example\n"
138171 "-------\n"
139172 "\n"
140−">>> z = zero_crossing_rate(a)";
173+">>> a = np.linspace(-1., 1., 1000, dtype=aubio.float_type)\n"
174+">>> aubio.zero_crossing_rate(a), 1/1000\n"
175+"(0.0010000000474974513, 0.001)\n"
176+"";
141177
142178 static char Py_min_removal_doc[] = ""
143−"min_removal(fvec) -> float\n"
179+"min_removal(vec)\n"
180+"\n"
181+"Remove the minimum value of a vector to each of its element.\n"
144182 "\n"
145−"Remove the minimum value of a vector, in-place modification\n"
183+"Modifies the input vector in-place and returns a reference to it.\n"
184+"\n"
185+"Parameters\n"
186+"----------\n"
187+"vec : fvec\n"
188+" input vector\n"
189+"\n"
190+"Returns\n"
191+"-------\n"
192+"fvec\n"
193+" modified input vector\n"
146194 "\n"
147195 "Example\n"
148196 "-------\n"
149197 "\n"
150−">>> min_removal(a)";
198+">>> aubio.min_removal(aubio.fvec(np.arange(1,4)))\n"
199+"array([0., 1., 2.], dtype=" AUBIO_NPY_SMPL_STR ")\n"
200+"";
151201
152202 extern void add_ufuncs ( PyObject *m );
153203 extern int generated_types_ready(void);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t