[C++-sig] boost.python and numpy.int32 on 64-bit system

Ger van Diepen diepen at astron.nl
Thu Apr 17 15:10:14 CEST 2008


Hi Andreas,

Thanks for your answer.
I'll have vacation in the coming 2 weeks, so I'll await your news.
I indeed think that numpy should have returned a normal Python type.

Cheers,
Ger

>>> Andreas Klöckner <lists at informa.tiker.net> 04/17/08 2:52 PM >>>
On Donnerstag 17 April 2008, Ger van Diepen wrote:
>   ArgumentError: Python argument types in
>     Table.getcell(table, str, numpy.int32)
                                ^^^^^^
>   did not match C++ signature:
>     getcell(casa::TableProxy {lvalue}, std::string columnname, int
rownr)

This is numpy's fault, as it returns what they term an 'array scalar'.
This is 
because Python's "int" on a 64-bit machine is 64 bits:

>>> 2**39
549755813888
>>> 2**66
73786976294838206464L

(see when the "L" shows up)

But numpy wants to return the exact data type you have in your array, so
it 
gives you something that's not an int. As BP doesn't know about numpy by

default (and can't assume it's there), there's no support. You would
need to 
install custom (from-/to-python) rvalue converters for numpy's array
scalars. 
I have something in the works that might help you--watch for an
announcement 
in the next few days. But for now the explicit conversion hack is
probably 
your easiest route to success.

Andreas




More information about the Cplusplus-sig mailing list