Revision: 439
http://rpy.svn.sourceforge.net/rpy/?rev=439&view=rev
Author: lgautier
Date: 2008-03-15 05:23:36 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Added handling of complex numbers
Modified Paths:
--------------
trunk/sandbox/rpy_nextgen/rpy/rinterface/rinterface.c
Modified: trunk/sandbox/rpy_nextgen/rpy/rinterface/rinterface.c
===================================================================
--- trunk/sandbox/rpy_nextgen/rpy/rinterface/rinterface.c 2008-03-15
11:29:00 UTC (rev 438)
+++ trunk/sandbox/rpy_nextgen/rpy/rinterface/rinterface.c 2008-03-15
12:23:36 UTC (rev 439)
@@ -1079,7 +1079,8 @@
{
SEXP sexp;
PyObject *seq_object, *item;
- seq_object = PySequence_Fast(object, "Cannot create R object from
non-sequence Python object.");
+ seq_object = PySequence_Fast(object,
+ "Cannot create R object from non-sequence Python
object.");
//FIXME: Isn't the call above supposed to fire an Exception ?
if (! seq_object) {
return NULL;
@@ -1160,6 +1161,23 @@
Py_DECREF(item);
}
}
+ break;
+ case CPLXSXP:
+ for (i = 0; i < length; ++i) {
+ item = PySequence_Fast_GET_ITEM(seq_object, i);
+ if (PyComplex_Check(item)) {
+ Py_complex cplx = PyComplex_AsCComplex(item);
+ COMPLEX(sexp)[i].r = cplx.real;
+ COMPLEX(sexp)[i].i = cplx.imag;
+ Py_DECREF(item);
+ }
+ else {
+ PyErr_Clear();
+ COMPLEX(sexp)[i].r = NA_REAL;
+ COMPLEX(sexp)[i].i = NA_REAL;
+ }
+ }
+ break;
//FIXME: add complex
default:
PyErr_Format(PyExc_ValueError, "cannot handle type %d", rType);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list