cf.Data.func

Data.func(f, *args, **kwargs)[source]

Apply an element-wise array operation to the data array in place.

Parameters :
f : function

The function to be applied.

args, kwargs :

Any arguments and keyword arguments passed to the function given by f.

Returns :

None

Examples

>>> print d.array
[[ 0.          1.57079633]
 [ 3.14159265  4.71238898]]
>>> import numpy
>>> d.func(numpy.cos)
>>> print d.array
[[ 1.0  0.0]
 [-1.0  0.0]]
>>> def f(x, y, a=0):
...     return x*y + a
...
>>> d.func(f, 2, a=10)
>>> print d.array
[[ 12.0  10.0]
 [-12.0  10.0]]

Previous topic

cf.Data.flip

Next topic

cf.Data.iterindices

This Page