other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
other:python:misc_by_jyp [2022/02/21 17:31] – [numpy related stuff] Added ufuncs jypeter | other:python:misc_by_jyp [2022/02/21 17:46] – [numpy related stuff] Added reduceat jypeter | ||
---|---|---|---|
Line 275: | Line 275: | ||
>>> | >>> | ||
(3.0, 4.5, 8.0)</ | (3.0, 4.5, 8.0)</ | ||
+ | |||
+ | === Applying a ufunc over specified sections of an array === | ||
+ | |||
+ | The [[https:// | ||
+ | |||
+ | < | ||
+ | # We need to add the beginning index (0), AND remove the last index | ||
+ | # (reduceat will automatically go to the end of the input array | ||
+ | >>> | ||
+ | array([3, 3, 4]) | ||
+ | >>> | ||
+ | >>> | ||
+ | 10 | ||
+ | >>> | ||
+ | [0, 3, 6] | ||
+ | |||
+ | # Compute the sums over the selected intervals with just one call | ||
+ | >>> | ||
+ | array([3. , 4.5, 8. ])</ | ||
/* | /* |
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter