[C++-sig] [boost] Adding numpy support to boost::python

Philip Austin paustin at eos.ubc.ca
Sun Mar 12 22:04:44 CET 2006


Neal Becker writes:
 > Has anyone tried yet adding numpy support to boost::python?  Is the only
 > requirement to add "numpy" to load function, or are there more extensive
 > API changes from numarray to numpy?

The only real problem I've encountered is handling the new type
object. e.g.:

    >>> check(y.typecode());

in boost_1_33_1/libs/python/test/numpy.py will fail  because
the character id returned by
y.typecode() has been replaced by a new dtype object:

In [19]:import numpy as np

In [20]:npArray=np.zeros(5)

In [21]:print npArray.typecode()
---------------------------------------------------------------------------
exceptions.AttributeError                            Traceback (most recent call last)

/nfs/kite/users/phil/<ipython console> 

AttributeError: 'numpy.ndarray' object has no attribute 'typecode'

In [22]:print npArray.dtype
'<i4'

In [23]:print npArray.dtype.name
int32

In [24]:print npArray.dtype.num
7











More information about the Cplusplus-sig mailing list