Closed GoogleCodeExporter closed 9 years ago
Thanks for the report.
The short answer is that numpy objects aren't supported (and I've never tested
them)
so it's not strictly a bug if they don't work.
It's not unreasonable to expect them to work though, so the slightly longer
answer is
that the numpy integer isn't behaving like a plain int and so causes an infinite
loop. In particular:
>>> numpy.uint32(5) >> 64
5
which clearly isn't correct!:
>>> 5 >> 64
0
This is probably a C-level issue in numpy (shifting a 32-bit integer by 64 bits
doesn't have a defined behaviour in C).
I'll leave it open as a bug for now though until I decide if it makes sense to
explicitly support numpy types (or at least raise an exception rather than
hang!)
The workaround of course is just to cast to an int:
>>> b = Bits(uint=int(c), length=3)
Original comment by python.bitstring@googlemail.com
on 22 Mar 2010 at 12:55
Agreed, I already use the cast workaround.
It reasonable to not support numpy types, but I think it is wise to raise an
exception meanwhile. I spent quite
some time to find out that my code hung because I used a numpy type instead of
an int ;)
For the rest, bitstring is brilliant!
Original comment by s.t.optl...@gmail.com
on 22 Mar 2010 at 1:05
Thanks for the kind comment. Having reviewed the problem I think that I might
as well
support the numpy type in this (although not officially). The problem is caused
by a
rather over-zealous optimisation of mine which I can just revert.
Original comment by python.bitstring@googlemail.com
on 24 Mar 2010 at 8:50
Fixed in revision 680.
Original comment by python.bitstring@googlemail.com
on 25 Mar 2010 at 10:14
Original issue reported on code.google.com by
s.t.optl...@gmail.com
on 22 Mar 2010 at 12:27