[Numpy-discussion] How do I do this?
Christopher Barker
Chris.Barker@noaa....
Sat Aug 30 18:24:58 CDT 2008
Stéfan van der Walt wrote:
> Maybe
>
> (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.
thanks all,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
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
mailing list