[Numpy-discussion] Use my own data type with NumPy

Günter Dannoritzer dannoritzer@web...
Wed Sep 5 16:59:23 CDT 2007

Christopher Barker wrote:
> Why would a FixPoint object have to look like a sequence, with a length 
> and a _getitem_? That's where the confusion is coming from.

That allows me to slice bits.

> If I understand your needs, a FixPoint object is a number -- you'll want 
> to override __add__ __mult__, and all those sorts of things, but there 
> should be no need to make it look like a sequence.
> What does the "length" of a fixed point number mean? What does it meant 
> to get the third element of a fixed point object?

Yes it returns the bit width. When indexing you can get individual bits
or a bit range. That is good for modeling hardware behavior.

> I'm guessing that maybe you're using __len__ to mean bit-width, but I'd 
> just have a property for that, and call it BitWidth or something.

That solved it. I took out __len__ and added a width property. Now array
is happy.


More information about the Numpy-discussion mailing list