On Monday 24 July 2006 12:23, Travis Oliphant wrote:
> Sebastian Haase wrote:
> > Hi,
> > I have a (medical) image file.
> > I wrote a nice interface based on memmap using numarray.
> > The class design I used  was essentially to return a numarray array
> > object with a new "custom" attribute giving access to special
> > information about the base file.
> >
> > Now with numpy I noticed that a numpy object does not allow adding new
> > attributes !! (How is this ? Why ?)
> >
> > Travis already suggested (replying to one of my last postings) to create
> > a new sub class of numpy.ndarray.
> >
> > But how do I initialize an object of my new class to be "basically
> > identically to" an existing ndarray object ?
> > Normally I could do
> > class B(N.ndarray):
> >     pass
> > a=N.arange(10)
> > a.__class__ = B
> >
> > BUT I get this error:
> > #>>> a.__class__ = B
> > Traceback (most recent call last):
> >    File "<input>", line 1, in ?
> > TypeError: __class__ assignment: only for heap types
> >
> > What is a "heap type" ? Why ?  How can I do what I want ?
>
> A heap type is one created in Python (i.e. not builtin with C).
>
> You should be able to do
>
> a = a.view(B)
>
> -Travis
Thanks  - (I'm just replying because I assume your helpful answer was 
mistakenly sent to me only and did not make it to the list)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to