[C++-sig] numarray 1.0 and BPL - s small fix ?

Francois Ostiguy ostiguy at fnal.gov
Wed Sep 1 19:47:14 CEST 2004


Hi -

I recently have been playing with numarray 1.0 and the associated
support for the array type in BPL. One of the first thing I noticed is
that

a.nelements();

where a is a numeric::array, fails with the message

TypeError: No registered converter was able to produce a C++ rvalue of
type long from this Python object of type builtin_function_or_method

I found the following thread in the archive, but apparently there was no
resolution:

http://aspn.activestate.com/ASPN/Mail/Message/2033918


Looking at the source, (BPL 1_31 and current CVS ) I see
the following code in the file libs/python/src/numeric.cpp:

...

long array_base::nelements() const
{
    return extract<long>attr("nelements");
}


I think this code should be replaced (at least for numarray 1.0 ) with

long array_base::nelements() const
 {
    return attr("nelements")();
 }

At least, this works for me. Perhaps nelements was a simple scalar
attribute in the old numeric extension ?


-Francois

----------------------------------------------------------------------------
Dr. Jean-Francois OSTIGUY                              voice: (630) 840-2231
Beam Physics Dept MS220                                  FAX: (630) 840-6039
Fermi National Accelerator Laboratory                email: ostiguy at fnal.gov
Batavia IL 60510-0500                           WWW:www-ap.fnal.gov/~ostiguy




More information about the Cplusplus-sig mailing list