numeric module

Steven Bethard steven.bethard at gmail.com
Fri Apr 1 13:15:42 EST 2005


shama.bell at gmail.com wrote:
> Hello,
> What's the problem with this code? I get the following error message:
> 
>  File "test.py", line 26, in test
>     print tbl[wi][bi]
> IndexError: index must be either an int or a sequence
> 
> ---code snippet----
> 
> from Numeric import *
> tbl = zeros((32, 16))
> 
> def test():
> 
>     val = testme()
>     wi = crc >> 4
>     bi = crc & 0xFL
>     print wi
>     print bi
>     print tbl[wi][bi]
> 
> 
> def testme():
>     val = 0xFFFFFFL
>     val >>= 23
>     return val
> 
>         
> if __name__ == '__main__':
>     test()

Hmm...  I can't reproduce this with numarray.  Maybe this only exists in 
Numeric?  Are you sure that the code here is what produced the error?

py> import numarray as na
py> tbl = na.zeros((32, 16))
py> def test():
...     val = testme()
...     wi = val >> 4
...     bi = val & 0xFL
...     print wi
...     print bi
...     print tbl[wi][bi]
...
py> def testme():
...     val = 0xFFFFFFL
...     val >>= 23
...     return val
...
py> test()
0
1
0

STeVe



More information about the Python-list mailing list