Small fix

master
pbrod 9 years ago
parent d04c28df0d
commit 9d5c4adb64

@ -162,7 +162,7 @@ def piecewise(condlist, funclist, xi=None, fill_value=0.0, args=(), **kw):
if len(condlist) == len(funclist)-1: if len(condlist) == len(funclist)-1:
condlist.append(otherwise_condition(condlist)) condlist.append(otherwise_condition(condlist))
if xi is None: if xi is None:
arrays = condlist arrays = ()
dtype = np.result_type(*funclist) dtype = np.result_type(*funclist)
else: else:
if not isinstance(xi, tuple): if not isinstance(xi, tuple):
@ -170,7 +170,7 @@ def piecewise(condlist, funclist, xi=None, fill_value=0.0, args=(), **kw):
arrays = np.broadcast_arrays(*xi) arrays = np.broadcast_arrays(*xi)
dtype = np.result_type(*arrays) dtype = np.result_type(*arrays)
out = valarray(arrays[0].shape, fill_value, dtype) out = valarray(condlist[0].shape, fill_value, dtype)
for cond, func in zip(condlist, funclist): for cond, func in zip(condlist, funclist):
if isinstance(func, collections.Callable): if isinstance(func, collections.Callable):
temp = tuple(np.extract(cond, arr) for arr in arrays) + args temp = tuple(np.extract(cond, arr) for arr in arrays) + args

Loading…
Cancel
Save