Revision: 725
          http://rpy.svn.sourceforge.net/rpy/?rev=725&view=rev
Author:   lgautier
Date:     2008-12-20 10:49:58 +0000 (Sat, 20 Dec 2008)

Log Message:
-----------

- Edits to the doc
rlike:
- pop() for TaggedList now returns the "popped" element
robjects:
- rclass is now a property (and the original rclass moved to getrclass())
- names is now a property
 

Modified Paths:
--------------
    rpy2/branches/version_2.0.x/NEWS
    rpy2/branches/version_2.0.x/doc/source/conf.py
    rpy2/branches/version_2.0.x/doc/source/introduction.rst
    rpy2/branches/version_2.0.x/doc/source/overview.rst
    rpy2/branches/version_2.0.x/doc/source/rlike.rst
    rpy2/branches/version_2.0.x/doc/source/robjects.rst
    rpy2/branches/version_2.0.x/rpy/rlike/container.py
    rpy2/branches/version_2.0.x/rpy/rlike/tests/test_container.py
    rpy2/branches/version_2.0.x/rpy/robjects/__init__.py
    rpy2/branches/version_2.0.x/rpy/robjects/tests/testRDataFrame.py
    rpy2/branches/version_2.0.x/rpy/robjects/tests/testRFormula.py
    rpy2/branches/version_2.0.x/rpy/robjects/tests/testRObject.py

Modified: rpy2/branches/version_2.0.x/NEWS
===================================================================
--- rpy2/branches/version_2.0.x/NEWS    2008-12-19 21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/NEWS    2008-12-20 10:49:58 UTC (rev 725)
@@ -2,6 +2,23 @@
 Release 2.0.1
 =============
 
+New features
+------------
+
+:mod:`rpy2.robjects`:
+
+- Property `names` for the :class:`RVector` methods :meth:`getnames` 
+  and :meth:`setnames` (this was likely forgotten for Release 2.0.0).
+
+- Property `rclass` for :class:`RObjectMixin` 
+
+Changes
+-------
+
+:mod:`rpy2.robjects`:
+
+- :meth:`rclass` becomes :meth:`getrclass`
+
 Bugs fixed
 ----------
 
@@ -11,6 +28,14 @@
 - Setup.py has no longer a (possibly outdated) static hardcoded version number
   for rpy2
 
+- Testing no longer stops with an error in the absence of the third-party
+  module :mod:`numpy`
+
+- :meth:`rpy2.rlike.container.TaggedList.pop` is now returning the element
+  matching the given index
+
+
+
 Release 2.0.0
 =============
 

Modified: rpy2/branches/version_2.0.x/doc/source/conf.py
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/conf.py      2008-12-19 21:53:06 UTC 
(rev 724)
+++ rpy2/branches/version_2.0.x/doc/source/conf.py      2008-12-20 10:49:58 UTC 
(rev 725)
@@ -45,7 +45,7 @@
 # The short X.Y version.
 version = '2.0'
 # The full version, including alpha/beta/rc tags.
-release = '2.0.0'
+release = '2.0.1'
 releaselevel = ''
 
 # There are two options for replacing |today|: either, you set today to some

Modified: rpy2/branches/version_2.0.x/doc/source/introduction.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/introduction.rst     2008-12-19 
21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/doc/source/introduction.rst     2008-12-20 
10:49:58 UTC (rev 725)
@@ -50,8 +50,14 @@
 >>> robjects.r['pi']
 3.14159265358979
 
+.. note::
 
+   Under the hood, the variable `pi` is gotten by default from the
+   R *base* package, unless an other variable with the name `pi` was
+   created in the `globalEnv`. The Section :ref:`robjects-environments`
+   tells more about that.
 
+
 Evaluating R code
 -----------------
 
@@ -106,7 +112,14 @@
 `f`. That function `f` is present in the R `Global Environement`, and can
 be accessed with the `__getitem__` mechanism outlined above:
 
+>>> robjects.globalEnv['f']
+function (r) 
+{
+    2 * pi * r
+}
 
+or 
+
 >>> robjects.r['f']
 function (r) 
 {
@@ -207,7 +220,7 @@
    By default, calling R functions will return R objects.
 
 
-More information on functions is in Section :ref:`robjects-functions`
+More information on functions is in Section :ref:`robjects-functions`.
 
 
 Examples
@@ -234,12 +247,18 @@
   r.layout(r.matrix(robjects.IntVector([1,2,3,2]), nrow=2, ncol=2))
   r.plot(r.runif(10), y, xlab="runif", ylab="foo/bar", col="red")
 
+Setting dynamically the number of arguments in a function call can be
+done the usual way in python
+
+.. code-block:: python
+
+  args = [x, y]
   kwargs = {'ylab':"foo/bar", 'type':"b", 'col':"blue", 'log':"x"}
-  r.plot(x, y, **kwargs)
+  r.plot(*args, **kwargs)
 
 .. note::
    Since the named parameters are a Python :class:`dict`, 
-   the order of the parameters is lost. 
+   the order of the parameters is lost for `**kwargs` arguments. 
 
 
 Linear models
@@ -279,8 +298,37 @@
    lm_D90 = r.lm("weight ~ group - 1")
    print(r.summary(lm_D90))
 
+Q:
+   Now how extract data from the resulting objects ?
+
+A:
+   The same, never it is. On the R object all depends.
+
+When taking the results from the code above, one could go like:
+
+>>> print(lm_D9.rclass)
+[1] "lm" 
+
+Here the resulting object is a list structure, as either inspecting
+the data structure or reading the R man pages for `lm` would tell us.
+Checking its element names is then trivial:
+
+>>> print(lm_D9.names)
+ [1] "coefficients"  "residuals"     "effects"       "rank"         
+ [5] "fitted.values" "assign"        "qr"            "df.residual"  
+ [9] "contrasts"     "xlevels"       "call"          "terms"        
+[13] "model" 
+
+And so is extracting a particular element:
+
+>>> print(lm_D9.r['coefficients'])
+$coefficients
+(Intercept)    groupTrt 
+      5.032      -0.371 
+
+More about extracting elements from vectors is available
+at :ref:`robjects-vectors-indexing`.
    
-
 Principal component analysis
 ----------------------------
 

Modified: rpy2/branches/version_2.0.x/doc/source/overview.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-12-19 21:53:06 UTC 
(rev 724)
+++ rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-12-20 10:49:58 UTC 
(rev 725)
@@ -159,8 +159,13 @@
 matter most. Here the programmer gets close(r) to R's C-level
 API.
 
+:mod:`rpy2.rlike`
+^^^^^^^^^^^^^^^^^
 
+Data structures and functions to mimic some of R's features and specificities
 
+
+
 Design notes
 ------------
 

Modified: rpy2/branches/version_2.0.x/doc/source/rlike.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/rlike.rst    2008-12-19 21:53:06 UTC 
(rev 724)
+++ rpy2/branches/version_2.0.x/doc/source/rlike.rst    2008-12-20 10:49:58 UTC 
(rev 725)
@@ -119,13 +119,11 @@
 (although more flexibility can be achieved using their
 method :meth:`iterontags`):
 
-
 >>> import rpy2.rlike.container as rlc
 >>> tl = rlc.TaggedList([1, 2, 3], tags = ('a', 'b', 'a'))
 >>> rlf.tapply(tl, tl.tags(), sum)
 [('a', 4), ('b', 2)]
 
-
 .. module:: rpy2.rlike.indexing
 
 Indexing
@@ -133,16 +131,18 @@
 
 Much of the R-style indexing can be achieved with Python's list comprehension:
 
->>> x = ('a', 'b', 'c')
->>> x_i = (0, 2)
->>> [x[i] for i in x_i]
+>>> l = ('a', 'b', 'c')
+>>> l_i = (0, 2)
+>>> [l[i] for i in l_i]
 ['a', 'c']
 
 In `R`, negative indexes mean that values should be excluded. Again,
-list comprehension can be used:
+list comprehension can be used (although this is not the most efficient way):
 
->>> x = ('a', 'b', 'c') 
->>> x_i = (0, 2)
+>>> l = ('a', 'b', 'c') 
+>>> l_i = (-1, -2)
+>>> [x for i, x in enumerate(l) if -i not in l_i]
+['a']
 
 .. function:: order(seq, cmp = default_cmp, reverse = False)
 
@@ -161,4 +161,4 @@
 >>> o
 [0, 2, 1]
 >>> [x[i] for i in o]
-['a', 'b', 'c']
\ No newline at end of file
+['a', 'b', 'c']

Modified: rpy2/branches/version_2.0.x/doc/source/robjects.rst
===================================================================
--- rpy2/branches/version_2.0.x/doc/source/robjects.rst 2008-12-19 21:53:06 UTC 
(rev 724)
+++ rpy2/branches/version_2.0.x/doc/source/robjects.rst 2008-12-20 10:49:58 UTC 
(rev 725)
@@ -220,6 +220,8 @@
 .. index::
    pair: RVector;indexing
 
+.. _robjects-vectors-indexing:
+
 Indexing
 --------
 
@@ -393,6 +395,8 @@
    :members:
 
 
+.. _robjects-environments:
+
 Environments
 ============
 

Modified: rpy2/branches/version_2.0.x/rpy/rlike/container.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/rlike/container.py  2008-12-19 21:53:06 UTC 
(rev 724)
+++ rpy2/branches/version_2.0.x/rpy/rlike/container.py  2008-12-20 10:49:58 UTC 
(rev 725)
@@ -246,13 +246,26 @@
             yield tag
 
     def pop(self, index=None):
+        """
+        Pop the item at a given index out of the list
+
+        :param index: integer
+        
+        """
         if index is None:
             index = len(self) - 1
         
-        super(TaggedList, self).pop(index)
+        res = super(TaggedList, self).pop(index)
         self.__tags.pop(index)
+        return res
 
     def remove(self, value):
+        """ 
+        Remove a given value from the list.
+        
+        :param value: object
+        
+        """
         found = False
         for i in xrange(len(self)):
             if self[i] == value:
@@ -262,6 +275,7 @@
             self.pop(i)
 
     def reverse(self):
+        """ Reverse the order of the elements in the list. """
         super(TaggedList, self).reverse()
         self.__tags.reverse()
 

Modified: rpy2/branches/version_2.0.x/rpy/rlike/tests/test_container.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/rlike/tests/test_container.py       
2008-12-19 21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/rpy/rlike/tests/test_container.py       
2008-12-20 10:49:58 UTC (rev 725)
@@ -186,12 +186,14 @@
         tv = [1,2,3]
         tl = rlc.TaggedList(tv, tags = tn)
         self.assertEquals(3, len(tl))
-        tl.pop()
+        elt = tl.pop()
+        self.assertEquals(3, elt)
         self.assertEquals(2, len(tl))
         self.assertEquals(tl.tags(), ('a', 'b'))
         self.assertEquals(tuple(tl), (1, 2))
 
-        tl.pop(0)
+        elt = tl.pop(0)
+        self.assertEquals(1, elt)
         self.assertEquals(1, len(tl))
         self.assertEquals(tl.tags(), ('b', ))
 

Modified: rpy2/branches/version_2.0.x/rpy/robjects/__init__.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/robjects/__init__.py        2008-12-19 
21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/rpy/robjects/__init__.py        2008-12-20 
10:49:58 UTC (rev 725)
@@ -144,10 +144,11 @@
         """
         return repr_robject(self, linesep='\n')
 
-    def rclass(self):
+    def getrclass(self):
         """ Return the name of the R class for the object. """
         return baseNameSpaceEnv["class"](self)
 
+    rclass = property(getrclass)
 
 class RObject(RObjectMixin, rinterface.Sexp):
     """ Base class for all R objects. """
@@ -283,6 +284,10 @@
         res = r["names<-"](self, value)
         return res
 
+    names = property(getnames, setnames, 
+                     "Names for the items in the vector.")
+
+
 class StrVector(RVector):
     """ Vector of string elements """
     def __init__(self, obj):

Modified: rpy2/branches/version_2.0.x/rpy/robjects/tests/testRDataFrame.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/robjects/tests/testRDataFrame.py    
2008-12-19 21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/rpy/robjects/tests/testRDataFrame.py    
2008-12-20 10:49:58 UTC (rev 725)
@@ -13,7 +13,7 @@
         df = robjects.RDataFrame(rlc.TaggedList((letters, numbers),
                                                 tags = ('letters', 'numbers')))
 
-        self.assertEquals("data.frame", df.rclass()[0])
+        self.assertEquals("data.frame", df.rclass[0])
 
     def testNewFromRObject(self):
         numbers = robjects.r('1:5')

Modified: rpy2/branches/version_2.0.x/rpy/robjects/tests/testRFormula.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/robjects/tests/testRFormula.py      
2008-12-19 21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/rpy/robjects/tests/testRFormula.py      
2008-12-20 10:49:58 UTC (rev 725)
@@ -6,12 +6,12 @@
 
     def testNew(self):
         fml = robjects.RFormula("y ~ x")
-        self.assertEquals("formula", fml.rclass()[0])
+        self.assertEquals("formula", fml.rclass[0])
         
     def testGetenvironment(self):
         fml = robjects.RFormula("y ~ x")
         env = fml.getenvironment()
-        self.assertEquals("environment", env.rclass()[0])
+        self.assertEquals("environment", env.rclass[0])
 
     def testSetenvironment(self):
         fml = robjects.RFormula("y ~ x")

Modified: rpy2/branches/version_2.0.x/rpy/robjects/tests/testRObject.py
===================================================================
--- rpy2/branches/version_2.0.x/rpy/robjects/tests/testRObject.py       
2008-12-19 21:53:06 UTC (rev 724)
+++ rpy2/branches/version_2.0.x/rpy/robjects/tests/testRObject.py       
2008-12-20 10:49:58 UTC (rev 725)
@@ -32,11 +32,11 @@
 
     def testRclass(self):
         self.assertEquals("character",
-                          robjects.baseNameSpaceEnv["letters"].rclass()[0])
+                          robjects.baseNameSpaceEnv["letters"].rclass[0])
         self.assertEquals("numeric",
-                          robjects.baseNameSpaceEnv["pi"].rclass()[0])
+                          robjects.baseNameSpaceEnv["pi"].rclass[0])
         self.assertEquals("function",
-                          robjects.globalEnv.get("help").rclass()[0])
+                          robjects.globalEnv.get("help").rclass[0])
 
     def testDo_slot(self):
         self.assertEquals("A1.4, p. 270",


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to