diff --git a/wafo/kdetools/gridding.py b/wafo/kdetools/gridding.py index f2e3cfd..dec00da 100644 --- a/wafo/kdetools/gridding.py +++ b/wafo/kdetools/gridding.py @@ -215,7 +215,7 @@ def accum(accmap, a, func=None, shape=None, fill_value=0, dtype=None): # Create the output array. out = np.empty(shape, dtype=dtype) - for s in product(*[np.arange(k) for k in shape]): + for s in product(*[list(range(k)) for k in shape]): if vals[s] == []: out[s] = fill_value else: @@ -249,7 +249,7 @@ def _gridcount_nd(acfun, data, x, y, w, binx): c = np.reshape(c / w, c_shape, order='F') - T = np.arange(d).tolist() + T = list(range(d)) T[1], T[0] = T[0], T[1] # make sure c is stored in the same way as meshgrid c = c.transpose(*T) diff --git a/wafo/misc.py b/wafo/misc.py index a974ccf..1b14dfb 100644 --- a/wafo/misc.py +++ b/wafo/misc.py @@ -204,13 +204,15 @@ def piecewise(condlist, funclist, xi=None, fill_value=0.0, args=(), **kw): if xi is None: arrays = () dtype = np.result_type(*funclist) + shape = condlist[0].shape else: if not isinstance(xi, tuple): xi = (xi,) arrays = np.broadcast_arrays(*xi) dtype = np.result_type(*arrays) + shape = arrays[0].shape - out = valarray(condlist[0].shape, fill_value, dtype) + out = valarray(shape, fill_value, dtype) for cond, func in zip(condlist, funclist): if cond.any(): if isinstance(func, collections.Callable):