December 2017
Intermediate to advanced
386 pages
10h 42m
English
All scalar functions defined in NumPy follow the ufunc protocol, so that when applied to an array, they are applied to every array item. The following example shows you how to compute the sine function for all elements of a one-dimensional array:
x = np.pi * np.arange(0, 2, 0.25)y = np.sin(x)
In this code, we first create an array x with equally spaced values. Then, with the np.sin(x) expression, we compute an array y containing the value of the sine function evaluated at each item of the array x.
It is important to notice that ufunc functions will operate on arrays with an arbitrary number of dimensions. For a unary ufunc, that is, a function that admits a single argument, the shape of the ...
Read now
Unlock full access