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
10static char aubio_module_doc[] = "Python module for the aubio library";10static char aubio_module_doc[] = "Python module for the aubio library";
11 11
12static char Py_alpha_norm_doc[] = ""12static char Py_alpha_norm_doc[] = ""
13"alpha_norm(fvec, integer) -> float\n"13"alpha_norm(vec, alpha)\n"
14"\n"14"\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"
16"\n"28"\n"
17"Example\n"29"Example\n"
18"-------\n"30"-------\n"
19"\n"31"\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"";
21 44
22static char Py_bintomidi_doc[] = ""45static char Py_bintomidi_doc[] = ""
23"bintomidi(fftbin, samplerate, fftsize)\n"46"bintomidi(fftbin, samplerate, fftsize)\n"
@@ -130,24 +153,51 @@ static char Py_freqtobin_doc[] = "" · 106 unmodified lines
130"";153"";
131 154
132static char Py_zero_crossing_rate_doc[] = ""155static 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"
134"\n"164"\n"
135"Compute Zero crossing rate of a vector\n"165"Returns\n"
166"-------\n"
167"float\n"
168" Zero-crossing rate.\n"
136"\n"169"\n"
137"Example\n"170"Example\n"
138"-------\n"171"-------\n"
139"\n"172"\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"";
141 177
142static char Py_min_removal_doc[] = ""178static 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"
144"\n"182"\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"
146"\n"194"\n"
147"Example\n"195"Example\n"
148"-------\n"196"-------\n"
149"\n"197"\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"";
151 201
152extern void add_ufuncs ( PyObject *m );202extern void add_ufuncs ( PyObject *m );
153extern int generated_types_ready(void);203extern 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