[Numpy-discussion] How do I do this?
Sat Aug 30 18:24:58 CDT 2008
Stéfan van der Walt wrote:
> (np.sign(a) | 1) * np.maximum(np.abs(a), min_value)
> is a little bit easier on the eye.
nice! that does it. somehow I never think of using or.
Alan G Isaac wrote:
> idx = np.abs(a)<min_value
> a[idx] = min_value*(np.sign(a[idx]) + (a[idx]==0))
that's do it too, but it's a bit more wordy, and I'm guessing slower,
though that's really irrelevant here.
Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion