Robert Kern wrote: > On Fri, Jun 17, 2011 at 13:27, Christopher Barker <[email protected]> > wrote: > >> Actually, I'm a bit confused about dtypes from an OO design perspective >> anyway. I note that the dtypes seem to have all (most?) of the methods >> of ndarrays (or placeholders, anyway), which I don't quite get. > > No, they don't. |33> d = np.dtype(float)
[~] |34> dir(d)... > The numpy *scalar* types do, OK -- that is, indeed, what I observed, from: dir(np.uint16) ... > because they are actual Python types just > like any other. They provide the *unbound* methods (i.e. you cannot > call them) that will be bound when an instance of it gets created. And > the scalar types have many of the same methods as ndarray to allow > some ability to write generic functions that will work with either > arrays or scalars. That's handy. I guess I'm confused about the difference between: np.dtype(uint16) and np.uint16 since I always pass in the later when a dtype is called for. -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 [email protected] _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
