matrix-entropy
matrix-entropy copied to clipboard
Some functions could be condensed through numpy
Noticing some places where some use of numpy functions would be more efficient!
https://github.com/cosmoharrigan/matrix-entropy/blob/master/calculate_profile.py#L43
So I think an easier way to do the dict(Counter(...))
would be to use `numpy.unique(..., return_counts=True).
But the larger issue was that moving window function (https://github.com/cosmoharrigan/matrix-entropy/blob/master/moving_window_filter.py#L11) could be computed using scipy.convolve2d
(https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve2d.html). It feels more natural to rely on natural operations like convolution rather than doing the triple-nested for-loops.
Felt like some functions could stay more within the numpy/scipy ecosystem, for such a matrix heavy calculation. Just my two cents!