I'm having a problem with PyArray_Check. If I just call
PyArray_Check(args) I don't have a problem, but if I try to assign the
result to anything, etc., it crashes (due to acces violation). So, for
example the code at the end of this note doesn't work, yet I know an array
is being passed and I can, for example, calculate its trace correctly if I
type cast it as a PyArrayObject*.
Also, a more general question: is this the recommended way to input numpy
arrays when using swig, or do most …
[View More]people find it easier to use more
elaborate typemaps, or something else?
Finally, I apologize if this is the wrong forum to post this question.
Please let me know.
Thanks, Tom
Method from C++ class:
PyObject * Test01::trace(PyObject * args)
{
if (!(PyArray_Check(args))) { // <- crashes here
PyErr_SetString(PyExc_ValueError, "must use NumPy array");
return NULL;
}
return NULL;
}
Swig file: (where typemaps are the ones included with most recent swig)
/* TMatrix.i */
%module Ptest
%include "typemaps.i"
%{
#include "Test01.h"
%}
class Test01
{
public:
PyObject * trace(PyObject *INPUT);
Test01();
virtual ~Test01();
};
Python code:
import Ptest
t = Ptest.Test01()
import Numeric
a = Numeric.arange(1.1, 2.7, .1)
b = Numeric.reshape(a, (4,4))
x = t.trace(b)
[View Less]
I would like a single precision version of 'interp' in the Numeric
Core. (I want such a routine since I'm operating on huge single
precision arrays, that I don't want promoted to double precision.)
I've written such a routine, but Paul Dubois and I are discussing the
best way of integrating it into the core.
One solution is to simply add a new function 'interpf' to
arrayfnsmodule.c .
Another solution is to add a typecode=Float option to interp.
Any opinions on how this single precision …
[View More]version be handled?
--
Joe VanAndel
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: vanandel(a)ucar.edu
[View Less]