Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use labeled_comprehension directly in more function in ndmeasure (#74)
* Use NumPy's `mean` with `labeled_comprehension` When computing a label's mean, NumPy's `mean` function can be used directly with `labeled_comprehension`. As `labeled_comprehension` is already being used by `mean` under the hood given that is what `sum` uses. There is no reason not to just use `labeled_comprehension` directly in `mean` with the function that we would like to compute. After all each call to the user provided function includes all relevant values represented by the label. So NumPy's `mean` is accurate in this case. Should simplify the Dask graph of `mean` and the computation time needed. Also should benefit any other function using `mean`. * Use NumPy's `var` with `labeled_comprehension` When computing a label's variance, NumPy's `var` function can be used directly with `labeled_comprehension`. As `labeled_comprehension` is already being used by `variance` under the hood given that is what `sum` uses. There is no reason not to just use `labeled_comprehension` directly in `variance` with the function that we would like to compute. After all each call to the user provided function includes all relevant values represented by the label. So NumPy's `var` is accurate in this case. Should simplify the Dask graph of `variance` and the computation time needed. Also should benefit any other function using `variance`. * Use NumPy's `std` with `labeled_comprehension` When computing a label's standard deviation, NumPy's `std` function can be used directly with `labeled_comprehension`. As `labeled_comprehension` is already being used by `standard_deviation` under the hood given that is what `var` uses. There is no reason not to just use `labeled_comprehension` directly in `standard_deviation` with the function that we would like to compute. After all each call to the user provided function includes all relevant values represented by the label. So NumPy's `std` is accurate in this case. Should simplify the Dask graph of `standard_deviation` and the computation time needed. Also should benefit any other function using `standard_deviation`.
- Loading branch information