[Numpy-discussion] [EXTERNAL] Re: Strange PyArray_FromObject() behavior
Thu Feb 16 23:41:02 CST 2012
The problem occurs in function
PyArrayObject* obj_to_array_allow_conversion(PyObject* input,
in numpy.i (which is the numpy SWIG interface file that I authored and is in the numpy distribution). The argument "input" comes in as a python int of value 0, "typecode" is NPY_NOTYPE to signify that the type should be detected, and "is_new_object" is an output flag. This function calls
PyArray_FromObject(input, typecode, 0, 0)
This is, in fact, a part of the PyTrilinos package, specifically the Teuchos module (Teuchos is our general tools package). The context here is the Teuchos Comm classes' reduce() method, in this case a summation over processors. We will be working with Tpetra classes that are built on top of a Teuchos Comm class.
On Feb 16, 2012, at 9:37 PM, Val Kalatsky wrote:
> Hi Bill,
> Looks like you are running a very fresh version of numpy.
> Without knowing the build version and what's going on in the extension module I can't tell you much.
> The usual suspects would be:
> 1) Numpy bug, not too likely.
> 2) Incorrect use of PyArray_FromObject, you'll need to send more info.
> 3) Something is seriously corrupted, probably not the case, because segfault would follow quickly.
> Please provide more info.
> PS Is it something related to what we'll be working on (Trilinos)?
> On Thu, Feb 16, 2012 at 11:09 AM, Spotz, William F <email@example.com> wrote:
> I have a user who is reporting tests that are failing on his platform. I have not been able to reproduce the error on my system, but working with him, we have isolated the problem to unexpected results when PyArray_FromObject() is called. Here is the chain of events:
> In python, an integer is calculated. Specifically, it is
> len(result.errors) + len(result.failures)
> where result is a unit test result object from the unittest module. I had him verify that this value was in fact a python integer. In my extension module, this PyObject gets passed to the PyArray_FromObject() function in a routine that comes from numpy.i. What I expect, and what I typically get, is a numpy scalar array of type C long. I had my user print the result using PyObject_Print() and what he got was
> array([0:00:00], dtype=timedelta64[us])
> I am stuck as to why this might be happening. Any ideas?
> ** Bill Spotz **
> ** Sandia National Laboratories Voice: (505)845-0170 **
> ** P.O. Box 5800 Fax: (505)284-0154 **
> ** Albuquerque, NM 87185-0370 Email: firstname.lastname@example.org **
> NumPy-Discussion mailing list
More information about the NumPy-Discussion