From: Travis O. <oli...@ee...> - 2006-10-19 23:00:51
|
Christopher Barker wrote: >Travis Oliphant wrote: > > >>Actually something as simple as >> >>class InfoArray(N.ndarray): >> pass >> >>will allow you to add attributes to InfoArray. >> >> > >Well, sure, but how the heck do you initialize it? > > You use the same constructor as ndarray has. numpy.info(numpy.ndarray) If you want an array-like function that produces the array, you do array(obj).view(InfoArray) or wrap that up in your own function. There are many over-lapping ways to construct ndarray's. You can use all of these ways to construct instances of your own type by getting the ndarray and using the .view() method. -Travis |