Revision: 540 http://rpy.svn.sourceforge.net/rpy/?rev=540&view=rev Author: lgautier Date: 2008-06-01 03:54:18 -0700 (Sun, 01 Jun 2008)
Log Message: ----------- - automagic guessing of R_HOME on win32 (R RHOME seems to be working on win32 with R-2.7.0patched) - fixed types for numpy. More tests for numpy array (and considering dropping the (tentative) support for numarray and Numeric. Modified Paths: -------------- branches/rpy_nextgen/rpy/rinterface/__init__.py branches/rpy_nextgen/rpy/rinterface/array.c branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVectorNumeric.py Modified: branches/rpy_nextgen/rpy/rinterface/__init__.py =================================================================== --- branches/rpy_nextgen/rpy/rinterface/__init__.py 2008-05-30 09:23:36 UTC (rev 539) +++ branches/rpy_nextgen/rpy/rinterface/__init__.py 2008-06-01 10:54:18 UTC (rev 540) @@ -3,8 +3,6 @@ try: R_HOME = os.environ["R_HOME"] except KeyError: - if sys.platform == 'win32': - raise Exception("The variable R_HOME is not defined.") R_HOME = os.popen("R RHOME").readlines() #Twist if 'R RHOME' spits out a warning if R_HOME[0].startswith("WARNING"): Modified: branches/rpy_nextgen/rpy/rinterface/array.c =================================================================== --- branches/rpy_nextgen/rpy/rinterface/array.c 2008-05-30 09:23:36 UTC (rev 539) +++ branches/rpy_nextgen/rpy/rinterface/array.c 2008-06-01 10:54:18 UTC (rev 540) @@ -30,12 +30,13 @@ sexp_typekind(SEXP sexp) { switch (TYPEOF(sexp)) { - case REALSXP: return 'd'; - case INTSXP: return 'l'; + case REALSXP: return 'f'; + case INTSXP: return 'i'; //FIXME: handle strings ? //case STRSXP: return 'S'; - case CPLXSXP: return 'D'; - //case LGLSXP: return 'b'; + //FIXME: handle 'O' (as R list ?) + case CPLXSXP: return 'c'; + case LGLSXP: return 'b'; } return 0; } Modified: branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVectorNumeric.py =================================================================== --- branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVectorNumeric.py 2008-05-30 09:23:36 UTC (rev 539) +++ branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVectorNumeric.py 2008-06-01 10:54:18 UTC (rev 540) @@ -33,28 +33,34 @@ px = [1,-2,3] x = rinterface.SexpVector(px, rinterface.INTSXP) nx = numericModule.asarray(x) - self.assertEquals('i', nx.typecode()) + self.assertEquals(nx.dtype.kind, 'i') for orig, new in itertools.izip(px, nx): self.assertEquals(orig, new) - self.assertTrue(False) + # change value in the Python array... makes it change in the R vector + nx[1] = 12 + self.assertEquals(x[1], 12) + def testArrayStructDouble(self, numericModule): px = [1.0, -2.0, 3.0] x = rinterface.SexpVector(px, rinterface.REALSXP) nx = numericModule.asarray(x) - self.assertEquals('f', nx.typecode()) + self.assertEquals(nx.dtype.kind, 'f') for orig, new in itertools.izip(px, nx): self.assertEquals(orig, new) - self.assertTrue(False) + + # change value in the Python array... makes it change in the R vector + nx[1] = 333.2 + self.assertEquals(x[1], 333.2) def testArrayStructComplex(self, numericModule): px = [1+2j, 2+5j, -1+0j] x = rinterface.SexpVector(px, rinterface.CPLXSXP) nx = numericModule.asarray(x) - self.assertEquals('D', nx.typecode()) + self.assertEquals(nx.dtype.kind, 'c') for orig, new in itertools.izip(px, nx): self.assertEquals(orig, new) - self.assertTrue(False) + class SexpVectorNumericTestCase(unittest.TestCase): 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 rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list