From: Christopher B. <Chr...@no...> - 2006-05-02 00:06:37
|
Hi all, I was just trying to use the putmask() method to replace a bunch of values with the same value and got and error, where the putmask() function works fine: >>> import numpy as N >>> a = N.arange(5) >>> a array([0, 1, 2, 3, 4]) >>> a.putmask(a > 3, 3) Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: putmask: mask and data must be the same size >>> N.putmask(a, a > 3, 3) >>> a array([0, 1, 2, 3, 3]) and: >>> help (N.ndarray.putmask) putmask(...) a.putmask(values, mask) sets a.flat[n] = v[n] for each n where mask.flat[n] is TRUE. v can be scalar. indicates that it should work. -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 Chr...@no... |