Revision: 657
          http://rpy.svn.sourceforge.net/rpy/?rev=657&view=rev
Author:   lgautier
Date:     2008-10-12 11:49:08 +0000 (Sun, 12 Oct 2008)

Log Message:
-----------
- Mode editing in the doc.
- Attempt at fixing history in the console in examples
- Pydoc statements

Modified Paths:
--------------
    branches/rpy_nextgen/demos/radmin.py
    branches/rpy_nextgen/doc/source/overview.rst
    branches/rpy_nextgen/doc/source/rlike.rst
    branches/rpy_nextgen/doc/source/robjects.rst
    branches/rpy_nextgen/rpy/rlike/container.py
    branches/rpy_nextgen/rpy/robjects/__init__.py

Modified: branches/rpy_nextgen/demos/radmin.py
===================================================================
--- branches/rpy_nextgen/demos/radmin.py        2008-10-12 11:28:18 UTC (rev 
656)
+++ branches/rpy_nextgen/demos/radmin.py        2008-10-12 11:49:08 UTC (rev 
657)
@@ -434,9 +434,15 @@
     _view = None
     _evalButton = None
     _start_mark = None
+    _history = None #[]
+    _history_i = None #0
 
     def __init__(self):
         super(ConsolePanel, self).__init__()
+
+        self._history = [None, ] * 20
+        self._history_i = 0
+
         s_window = gtk.ScrolledWindow()
         s_window.set_policy(gtk.POLICY_AUTOMATIC, 
                             gtk.POLICY_AUTOMATIC)
@@ -476,15 +482,23 @@
 
         self._firstEnter = False
 
+        
     def actionKeyPress(self, view, event):
         if (event.keyval == gtk.gdk.keyval_from_name("Return")):
             self.append("\n", "input")
             self.evaluateAction(self._evalButton)
+            self._history_i = len(self._history) - 1
             return True
         if (event.keyval == gtk.gdk.keyval_from_name("Up")):
-            print('up')
+            self._history_i -= 1
+            if self._history_i == -1:
+                self._history_i = len(self._history)
+            return True
         if (event.keyval == gtk.gdk.keyval_from_name("Down")):
-            print('down')
+            self._history_i += 1
+            if self._history_i == len(self._history):
+                self._history_i = 0
+            return True
 
     def append(self, text, tag="input"):
         tag = self.tag_table.lookup(tag)
@@ -496,6 +510,10 @@
                                buffer.get_end_iter())
         buffer.delete_mark(mark)
 
+        if tag == "input":
+            self._history[self._history_i] = text
+            self._history_i += 1
+
     def evaluateAction(self, widget, data=None):
         buffer = self._buffer
         start_iter = buffer.get_iter_at_mark(self._start_mark)

Modified: branches/rpy_nextgen/doc/source/overview.rst
===================================================================
--- branches/rpy_nextgen/doc/source/overview.rst        2008-10-12 11:28:18 UTC 
(rev 656)
+++ branches/rpy_nextgen/doc/source/overview.rst        2008-10-12 11:49:08 UTC 
(rev 657)
@@ -31,7 +31,7 @@
 Naturally RPy2 is inspired by RPy, but also by A. Belopolskys's contributions
 that were waiting to be included into RPy.
 
-This effort can be seen as a rewrite of the RPy package.
+This effort can be seen as a redesign and rewrite of the RPy package.
 
 Installation
 ------------
@@ -150,12 +150,11 @@
 
 The choice of inheritance was made to facilitate the implementation
 of mostly inter-exchangeable classes between :mod:`rpy2.rinterface`
-and :mod:`rpy2.robjects`: an :class:`rpy2.rinterface.SexpClosure`
+and :mod:`rpy2.robjects`. For example, an :class:`rpy2.rinterface.SexpClosure`
 can be given any :class:`rpy2.robjects.RObject` as a parameter while
 any :class:`rpy2.robjects.RFunction` can be given any 
-:class:`rpy2.rinterface.Sexp`. Choosing inheritance does not only
-come with advantages: `setters` on `R` objects would be more intuitive
-with a container/delegation approach.
+:class:`rpy2.rinterface.Sexp`. Because of R's functional basis, 
+a container-like extension is also present.
 
 The module :mod:`rpy2.rpy_classic` is using delegation, letting us
 demonstrate how to extend :mod:`rpy2.rinterface` with an alternative

Modified: branches/rpy_nextgen/doc/source/rlike.rst
===================================================================
--- branches/rpy_nextgen/doc/source/rlike.rst   2008-10-12 11:28:18 UTC (rev 
656)
+++ branches/rpy_nextgen/doc/source/rlike.rst   2008-10-12 11:49:08 UTC (rev 
657)
@@ -83,14 +83,17 @@
 [1, 2, 3]
 >>> tl.tags()
 ('a', 'b', 'c')
->>> tl.settag(0, 'c')
+>>> tl.settag(2, 'a')
 >>> tl.tags()
-('c', 'b', 'c')
->>> it = tl.iterontag('c')
+('a', 'b', 'a')
+>>> it = tl.iterontag('a')
 >>> [x for x in it]
 [1, 3]
 
 
+>>> [(t, sum([i for i in tl.iterontag(t)])) for t in set(tl.itertags())]
+[('a', 4), ('b', 2)]
+
 The Python docstring for the class is:
 
 .. autoclass:: rpy2.rlike.container.TaggedList
@@ -102,13 +105,27 @@
 Tools for working with sequences
 ================================
 
+Tools for working with objects implementing the
+the sequence protocol can be found here.
+
+
 .. autofunction:: tapply
 
 >>> import rpy2.rlike.functional as rlf
 >>> rlf.tapply((1,2,3), ('a', 'b', 'a'), sum)
 [('a', 4), ('b', 2)]
 
+:class:`TaggedList` objects can be used with their tags
+(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

Modified: branches/rpy_nextgen/doc/source/robjects.rst
===================================================================
--- branches/rpy_nextgen/doc/source/robjects.rst        2008-10-12 11:28:18 UTC 
(rev 656)
+++ branches/rpy_nextgen/doc/source/robjects.rst        2008-10-12 11:49:08 UTC 
(rev 657)
@@ -67,7 +67,7 @@
 
   * The actual Python attributes for the object masks the R elements 
 
-  * '.' (dot) is syntactically valid name for R objects, but not for
+  * '.' (dot) is syntactically valid in names for R objects, but not for
     python objects.
 
 That last limitation can partly be removed by setting the attribute
@@ -79,7 +79,27 @@
 >>> robjects.r.as_null
 # R function as.null() returned
 
+.. warning::
+   In the case there are R objects which name only differ by '.' and '_'
+   (e.g., 'my_variable' and 'my.variable'), setting :attr:`_dotter` to True
+   can result in confusing results at runtime.
 
+Behind the scene, the steps for getting an attribute of `r` are
+rather straightforward:
+ 
+  1. Check if the attribute is defined as such in the python definition for
+     `r`
+
+  2. Check if the attribute is can be accessed in R, starting from `globalEnv`
+
+  3. If :attr:`_dotter` is True, turn all `_` into `.` and repeat the step 
above
+
+When safety matters most, we recommed using :meth:`__getitem__` to get
+and R object (and store it in a python variable if wanted):
+
+>>> as_null = robjects.r['as.null']
+
+
 Strings as R code
 -----------------
 
@@ -215,11 +235,14 @@
 >>> x.r + 1
 2:11
 
-
 .. note::
    In Python, the operator ``+`` concatenate sequence object, and this behavior
    has been conserved.
 
+.. note::
+   The boolean operator ``not`` cannot be redefined in Python (at least up to
+   version 2.5), and its behavior could be made to mimic R's behavior
+
 .. index::
    single: names; robjects
 
@@ -273,6 +296,8 @@
 (with :attr:`typeof` equal to *VECSXP*)
 or an instance of class :class:`rpy2.rlike.container.TaggedList`.
 
+>>> robjects.RDataFrame()
+
 .. autoclass:: rpy2.robjects.RDataFrame
    :show-inheritance:
    :members:
@@ -397,7 +422,7 @@
   fit = robjects.r('lm(%s)' %repr(fmla))
 
 
-Mapping between rpy2 objects and other python objects
+Mapping rpy2 objects to arbitrary python objects
 =====================================================
 
 The conversion, often present when working with RPy-1.x, is no longer
@@ -447,7 +472,10 @@
 <type 'float'>
 >>> 
 
+The default behavoir can be restored with:
 
+>>> robjects.ri2py = default_ri2py
+
 The docstrings for :meth:`default_ri2py`, :meth:`default_py2ri`, and 
:meth:`py2ro` are:
 
 .. autofunction:: rpy2.robjects.default_ri2py

Modified: branches/rpy_nextgen/rpy/rlike/container.py
===================================================================
--- branches/rpy_nextgen/rpy/rlike/container.py 2008-10-12 11:28:18 UTC (rev 
656)
+++ branches/rpy_nextgen/rpy/rlike/container.py 2008-10-12 11:49:08 UTC (rev 
657)
@@ -273,7 +273,6 @@
         super(TaggedList, self).sort(reverse = reverse)
         self.__tags = [self.__tags[i] for i in o]
 
-
     def tags(self):
         """
         Return a tuple of all tags
@@ -295,3 +294,15 @@
         self.__tags[i] = t
 
 
+# class DataFrame(ArgsDict):
+
+#     def __init__(self, s):
+#         super(ArgsDict, self).__init__(s)
+        
+#         if len(self) > 0:
+#             nrows = len(self[0])
+#             for i, v in enumerate(self):
+#                 if len(v) != nrows:
+#                     raise ValueError("Expected length %i for element %i" 
+#                                      %(nrows, i))
+                

Modified: branches/rpy_nextgen/rpy/robjects/__init__.py
===================================================================
--- branches/rpy_nextgen/rpy/robjects/__init__.py       2008-10-12 11:28:18 UTC 
(rev 656)
+++ branches/rpy_nextgen/rpy/robjects/__init__.py       2008-10-12 11:49:08 UTC 
(rev 657)
@@ -320,7 +320,14 @@
         return self.dim[1]
 
 class RDataFrame(RVector):
+    """ R 'data.frame'.
+    """
+
     def __init__(self, tlist):
+        """ Create a new data frame.
+
+        :param tlist: TaggedList
+        """
         if isinstance(tlist, rlc.TaggedList):
             df = baseNameSpaceEnv["data.frame"].rcall(tlist.items())
             super(RDataFrame, self).__init__(df)


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
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to