diff --git a/nifty/data_objects/distributed_do.py b/nifty/data_objects/distributed_do.py index cbddc0b14dcc73acaeb5f8f47267595edbff1843..b747284841459aef24c5d8c0a7946d2daea340cd 100644 --- a/nifty/data_objects/distributed_do.py +++ b/nifty/data_objects/distributed_do.py @@ -4,7 +4,7 @@ from mpi4py import MPI __all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full", "empty", "zeros", "ones", "empty_like", "vdot", "abs", "exp", - "log", "sqrt", "bincount", "from_object", "from_random", + "log", "sqrt", "from_object", "from_random", "local_data", "ibegin", "np_allreduce_sum", "distaxis", "from_local_data", "from_global_data", "to_global_data", "redistribute", "default_distaxis"] @@ -290,13 +290,6 @@ def sqrt(a, out=None): return _math_helper(a, np.sqrt, out) -def bincount(x, weights=None, minlength=None): - if weights is not None: - weights = weights._data - res = np.bincount(x._data, weights, minlength) - return data_object(res) - - def from_object(object, dtype=None, copy=True): return data_object(object._shape, np.array(object._data, dtype=dtype, copy=copy), diff --git a/nifty/data_objects/numpy_do.py b/nifty/data_objects/numpy_do.py index 4c2ed0a556dbd81e6ad0ddd555da09dc41f5c8b6..a347c0e629f33960610e039228dbbcf590dc9740 100644 --- a/nifty/data_objects/numpy_do.py +++ b/nifty/data_objects/numpy_do.py @@ -3,12 +3,12 @@ import numpy as np from numpy import ndarray as data_object from numpy import full, empty, empty_like, sqrt, ones, zeros, vdot, abs, \ - bincount, exp, log + exp, log from .random import Random __all__ = ["ntask", "rank", "master", "local_shape", "data_object", "full", "empty", "zeros", "ones", "empty_like", "vdot", "abs", "exp", - "log", "sqrt", "bincount", "from_object", "from_random", + "log", "sqrt", "from_object", "from_random", "local_data", "ibegin", "np_allreduce_sum", "distaxis", "from_local_data", "from_global_data", "to_global_data", "redistribute", "default_distaxis"] diff --git a/nifty/operators/fft_operator_support.py b/nifty/operators/fft_operator_support.py index 50f912320a9d32164ae184a2827734d77266f2c0..718e1e9bfca585e15fb700ad43107609cad1df03 100644 --- a/nifty/operators/fft_operator_support.py +++ b/nifty/operators/fft_operator_support.py @@ -66,12 +66,12 @@ class RGRGTransformation(Transformation): tmpax = (dobj.distaxis(x.val),) tmp = dobj.redistribute(x.val, nodist=tmpax) ldat = dobj.local_data(tmp) - ldat = fftn(ldat, axes=tmpax) - if len(axes) ==1: # we are done - ldat = ldat.real+ldat.imag + if len(axes) ==1: # only one transform needed + ldat = hartley(ldat, axes=tmpax) tmp = dobj.from_local_data(tmp.shape,ldat,distaxis=dobj.distaxis(tmp)) tmp = dobj.redistribute(tmp, dist=tmpax[0]) - else: + else: # two separate transforms + ldat = fftn(ldat, axes=tmpax) tmp = dobj.from_local_data(tmp.shape,ldat,distaxis=dobj.distaxis(tmp)) tmp = dobj.redistribute(tmp, dist=tmpax[0]) tmpax = tuple (i for i in axes if i not in tmpax) diff --git a/nifty/spaces/power_space.py b/nifty/spaces/power_space.py index c481789e8b982e86336a9ea4445cbab4e37a6949..9a47f112cdb6b52aa75f3cab24e04e1aeeb5e794 100644 --- a/nifty/spaces/power_space.py +++ b/nifty/spaces/power_space.py @@ -150,13 +150,12 @@ class PowerSpace(Space): minlength=nbin) temp_rho = dobj.np_allreduce_sum(temp_rho) assert not (temp_rho == 0).any(), "empty bins detected" + # The explicit conversion to float64 is necessary because bincount + # sometimes returns its result as an integer array, even when + # floating-point weights are present ... temp_k_lengths = np.bincount(dobj.local_data(temp_pindex).ravel(), weights=dobj.local_data(k_length_array.val).ravel(), - minlength=nbin) - # This conversion is necessary because bincount sometimes returns - # its result as an integer array, even when floating-point weights - # are present ... - temp_k_lengths = temp_k_lengths.astype(np.float64) + minlength=nbin).astype(np.float64) temp_k_lengths = dobj.np_allreduce_sum(temp_k_lengths) / temp_rho temp_dvol = temp_rho*pdvol self._powerIndexCache[key] = (binbounds,