|
From: Christopher B. <Chr...@no...> - 2008-06-12 16:12:47
|
Manuel Metz wrote: > x = np.asarray(x).astype(np.float32) > x = np.zeros( x, np.float_ ) > x = np.ones((col,), float) > > Is there a preferred one to stick to ?! Michael Droettboom wrote: > x = np.asarray(x, np.float_) I'd vote for: x = np.asarray(x, np.float) It ends up resulting in the same thing, but I prefer not to have magic-looking underscores in names. There is a slight difference: np.float is the python float type, whereas np.float_ is the numpy float64 type. I suppose in some future 128 bit OS, the python float may be something else. I like saying: "make this the standard python float type", rather than "make this a 64 bit float", even though it means the same thing in all versions of python I know of. This, or course, only when casting really is required, as John H. pointed out. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |