diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-04-08 14:12:19 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-04-08 15:01:26 -0700 |
commit | 4a178b2f21fbf55786c3cfe6c247d91cfb4155b2 (patch) | |
tree | 77570550c62126002755358eb9e7a30095bf3d5e /numpy/lib/histograms.py | |
parent | 40938e4367b3f6f0f368d71ec3e4722f58592cd8 (diff) | |
download | numpy-4a178b2f21fbf55786c3cfe6c247d91cfb4155b2.tar.gz |
MAINT: Remove pointless axis permutation
Diffstat (limited to 'numpy/lib/histograms.py')
-rw-r--r-- | numpy/lib/histograms.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py index a770e3d31..536dc9be7 100644 --- a/numpy/lib/histograms.py +++ b/numpy/lib/histograms.py @@ -926,11 +926,9 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None): hist = np.zeros(nbin, float).reshape(-1) # Compute the sample indices in the flattened histogram matrix. - ni = nbin.argsort() xy = np.zeros(N, np.intp) - for i in np.arange(0, D-1): - xy += Ncount[ni[i]] * nbin[ni[i+1:]].prod() - xy += Ncount[ni[-1]] + for i in np.arange(0, D): + xy += Ncount[i] * nbin[i+1:].prod() # Compute the number of repetitions in xy and assign it to the # flattened histmat. @@ -942,11 +940,7 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None): hist[a] = flatcount # Shape into a proper matrix - hist = hist.reshape(np.sort(nbin)) - for i in np.arange(nbin.size): - j = ni.argsort()[i] - hist = hist.swapaxes(i, j) - ni[i], ni[j] = ni[j], ni[i] + hist = hist.reshape(nbin) # Remove outliers (indices 0 and -1 for each dimension). core = D*(slice(1, -1),) |