[Numpy-discussion] embedded arrays

Robert Kern robert.kern at gmail.com
Fri Jun 6 18:27:22 EDT 2008


On Fri, Jun 6, 2008 at 17:10, Thomas Hrabe <thrabe at burnham.org> wrote:
> Hi all,
>
> while writing a extension module in C++ for python & numpy, I find a strange
> error.
>
> I can send and retrieve numpy arrays to and from my module.
> But python stops if I do the following:
>
> a = numpy.array([[1.1,2,3],[4,5,6]])
> PM.put(a,'a')   //send a to the module
> b = PM.get('a') //get a identical copy from the module
> print b
> array([[ 1.1,  2. ,  3. ],
>        [ 4. ,  5. ,  6. ]])
>
> b.__class__
> Out[36]: <type 'numpy.ndarray'>
>
>
> perfect, until
> a == b
>
> the interpreter does not continue from here...
> I can add values to to b, everything, but a == b simply crashes ...?
>
> Does anybody have a clue for this problem?

Not really. It probably depends on some details with your interfacing.
Since we don't have access to your code, we don't have much to go on.
You might have buggy reference counting or perhaps you gave the numpy
ndarray ownership of the array's memory when it actually shouldn't.
Memory issues can be a bit finicky where everything will work for a
while, then crash.

Try running your program under a C debugger like gdb so we can get a
backtrace. That might give us some more ideas about exactly where
problems are occurring.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list