History

[py] improve fvec doc

Paul Brossier committed 8 years ago

Commit 78c1d321 parent 6d8ae981 file · +49 −1Browse files

Unified · Split

python/lib/aubio/__init__.py+49−1
@@ -8,8 +8,56 @@ from .midiconv import * · 7 unmodified lines
8from .slicing import *8from .slicing import *
9 9
10class fvec(numpy.ndarray):10class fvec(numpy.ndarray):
11 """a numpy vector holding audio samples"""11 """fvec(input_arg=1024, **kwargs)
12 A vector holding float samples.
12 13
14 If `input_arg` is an `int`, a 1-dimensional vector of length `input_arg`
15 will be created and filled with zeros. Otherwise, if `input_arg` is an
16 `array_like` object, it will be converted to a 1-dimensional vector of
17 type :data:`float_type`.
18
19 Parameters
20 ----------
21 input_arg : `int` or `array_like`
22 Can be a positive integer, or any object that can be converted to
23 a numpy array with :func:`numpy.array`.
24 **kwargs
25 Additional keyword arguments passed to :func:`numpy.zeros`, if
26 `input_arg` is an integer, or to :func:`numpy.array`. Should not
27 include `dtype`, which is already specified as
28 :data:`aubio.float_type`.
29
30 Returns
31 -------
32 numpy.ndarray
33 Array of shape `(length,)`.
34
35 Examples
36 --------
37 >>> aubio.fvec(10)
38 array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)
39 >>> aubio.fvec([0,1,2])
40 array([0., 1., 2.], dtype=float32)
41 >>> a = np.arange(10); type(a), type(aubio.fvec(a))
42 (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)
43 >>> a.dtype, aubio.fvec(a).dtype
44 (dtype('int64'), dtype('float32'))
45
46 Notes
47 -----
48
49 In the Python world, `fvec` is simply a subclass of
50 :class:`numpy.ndarray`. In practice, any 1-dimensional `numpy.ndarray` of
51 `dtype` :data:`float_type` may be passed to methods accepting
52 `fvec` as parameter. For instance, `sink()` or `pvoc()`.
53
54 See Also
55 --------
56 cvec : a container holding spectral data
57 numpy.ndarray : parent class of :class:`fvec`
58 numpy.zeros : create a numpy array filled with zeros
59 numpy.array : create a numpy array from an existing object
60 """
13 def __new__(cls, input_arg=1024, **kwargs):61 def __new__(cls, input_arg=1024, **kwargs):
14 if isinstance(input_arg, int):62 if isinstance(input_arg, int):
15 if input_arg == 0:63 if input_arg == 0:

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