finite_op

PlasmaCalcs.tools.arrays.finite_op(arr, op, *, if_empty=UNSET)

returns op(arr), hitting only the finite values of arr.

arr: array-like or list of differently-sized array-like objects.
will do op(array, or list of arrays to flatten & concatenate).
if arr is a single array-like has only finite values,
finite_op(arr, op) == op(arr).
if arr is a single array-like and has some nonfinite values (infs or nans),
finite_op(arr, op) == op(arr[np.isfinite(arr)])
if np.asanyarray(arr) fails with ValueError,
attempt to interpret arr as a list of differently-sized array-like objects;
convert each to array via np.asanyarray, reshape(-1), then concatenate.
if_empty: UNSET or any value
value to return if arr is an empty array (or there are no finite values in it).
UNSET –> use numpy default behavior (e.g. np.mean([]) –> nan; np.min([]) –> crash)
any value –> return this value.