Revision: 695
http://rpy.svn.sourceforge.net/rpy/?rev=695&view=rev
Author: lgautier
Date: 2008-11-16 19:44:18 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
rpy2.rpy_classic:
- Robj.getSexp() replace by a property Robj.sexp
doc:
- Documentation about mixed usage of rpy_classic with rpy2.robjects or
rpy2.rinterface
- Edit in the overiew
Modified Paths:
--------------
rpy2/branches/version_2.0.x/doc/source/overview.rst
rpy2/branches/version_2.0.x/doc/source/rpy_classic.rst
rpy2/branches/version_2.0.x/rpy/rpy_classic.py
rpy2/branches/version_2.0.x/rpy/tests_rpy_classic.py
Modified: rpy2/branches/version_2.0.x/doc/source/overview.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-11-12 21:07:28 UTC
(rev 694)
+++ rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-11-16 19:44:18 UTC
(rev 695)
@@ -124,7 +124,7 @@
.. note::
At the time of writing, 2 unit tests will fail. Their failure
- is forced, because the terminating then starting again an
+ is forced, because terminating then starting again an
embbeded R is causing problems.
.. warning::
@@ -200,6 +200,10 @@
For the original RPy and its maintainance through the years.
Alexander Belopolsky.
- His code contribution to RPy is acknowledged. I have found great
- inspiration in reading that code.
+ His code contribution of an alternative RPy is acknowledged.
+ I have found great inspiration in reading that code.
+JRI
+ The Java-R Interface, and its authors, as answered to some
+ of the implementation questions were found there.
+
Modified: rpy2/branches/version_2.0.x/doc/source/rpy_classic.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/rpy_classic.rst 2008-11-12
21:07:28 UTC (rev 694)
+++ rpy2/branches/version_2.0.x/doc/source/rpy_classic.rst 2008-11-16
19:44:18 UTC (rev 695)
@@ -93,3 +93,55 @@
>>> pca = rpy.r.princomp(m)
>>> rpy.r.plot(pca, main = "PCA")
>>>
+
+
+Partial use of :mod:`rpy_classic`
+==================================
+
+The use of rpy_classic does not need to be
+exclusive of the other interface(s) proposed
+in rpy2.
+
+Chaining code designed for either of the interfaces
+is rather easy and, among other possible use-cases,
+should make the inclusion of legacy rpy code into newly
+written rpy2 code a simple take.
+
+The link between :mod:`rpy_classic` and the rest
+of :mod:`rpy2` is the property :attr:`RObj.sexp`,
+that give the representation of the underlying R object
+in the low-level :mod:`rpy2.rinterface` definition.
+This representation can then be used in function calls
+with :mod:`rpy2.rinterface` and :mod:`rpy2.robjects`.
+With :mod:`rpy2.robjects`, a conversion using
+:func:`rpy2.robjects.default_ri2py` can be considered.
+
+.. note::
+
+ Obviously, that property `sexp` is not part of the original
+ `Robj` in rpy.
+
+
+An example:
+
+.. code-block:: python
+
+ import rpy2.robjects as ro
+ import rpy2.rpy_classic as rpy
+ rpy.set_default_mode(rpy.NO_CONVERSION)
+
+
+ def legacy_paste(v):
+ # legacy rpy code
+ res = rpy.r.paste(v, collapse = '-')
+ return res
+
+
+ rletters = ro.r['letters']
+
+ # the legaxy code is called using an rpy2.robjects object
+ alphabet_rpy = legacy_paste(rletters)
+
+ # convert the resulting rpy2.rpy_classic object to
+ # an rpy2.robjects object
+ alphabet = ro.default_ri2py(alphabet_rpy.sexp)
Modified: rpy2/branches/version_2.0.x/rpy/rpy_classic.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/rpy_classic.py 2008-11-12 21:07:28 UTC
(rev 694)
+++ rpy2/branches/version_2.0.x/rpy/rpy_classic.py 2008-11-16 19:44:18 UTC
(rev 695)
@@ -221,8 +221,10 @@
return res
##FIXME: not part of RPy-1.x.
- def getSexp(self):
+ def get_sexp(self):
return self.__sexp
+
+ sexp = property(fget = get_sexp)
#def __repr__(self):
# res = rpy2py(self)
Modified: rpy2/branches/version_2.0.x/rpy/tests_rpy_classic.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/tests_rpy_classic.py 2008-11-12
21:07:28 UTC (rev 694)
+++ rpy2/branches/version_2.0.x/rpy/tests_rpy_classic.py 2008-11-16
19:44:18 UTC (rev 695)
@@ -1,6 +1,7 @@
import unittest
import rpy2.rpy_classic as rpy
+import rpy2.rinterface
class RpyClassicTestCase(unittest.TestCase):
@@ -27,6 +28,12 @@
self.assertTrue(callable(rpy.r.seq))
self.assertTrue(callable(rpy.r.pi))
+ def testSexp(self):
+ rpy.set_default_mode(rpy.NO_CONVERSION)
+ pi = rpy.r.pi
+ self.assertTrue(isinstance(pi.sexp, rpy2.rinterface.Sexp))
+ self.assertRaises(AttributeError, setattr, pi, 'sexp', None)
+
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(RpyClassicTestCase)
return suite
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list