Revision: 712 http://rpy.svn.sourceforge.net/rpy/?rev=712&view=rev Author: lgautier Date: 2008-12-03 12:09:01 +0000 (Wed, 03 Dec 2008)
Log Message: ----------- merging recent changes from version 2.0.x (doc + fix when using env variable R_HOME) Modified Paths: -------------- rpy2/trunk/NEWS rpy2/trunk/demos/example01.py rpy2/trunk/doc/source/conf.py rpy2/trunk/doc/source/index.rst rpy2/trunk/doc/source/overview.rst rpy2/trunk/doc/source/robjects.rst rpy2/trunk/rpy/__init__.py rpy2/trunk/rpy/rinterface/__init__.py rpy2/trunk/setup.py Added Paths: ----------- rpy2/trunk/doc/source/robjects_convert.rst Property Changed: ---------------- rpy2/trunk/doc/ Modified: rpy2/trunk/NEWS =================================================================== --- rpy2/trunk/NEWS 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/NEWS 2008-12-03 12:09:01 UTC (rev 712) @@ -1,7 +1,14 @@ -SVN -=== +Release 2.0.1 +============= +Bugs fixed +---------- + +- Having the environment variable R_HOME specified resulted in an error + when importing :mod:`rpy2.rinterface` # root of the problem spotted by Peter + + Release 2.0.0 ============= Modified: rpy2/trunk/demos/example01.py =================================================================== --- rpy2/trunk/demos/example01.py 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/demos/example01.py 2008-12-03 12:09:01 UTC (rev 712) @@ -26,13 +26,10 @@ r.biplot(pca, main="biplot") -if not r.require("GO")[0]: +if not r.require("GO.db")[0]: raise(Exception("Bioconductor Package GO missing")) goItem = r.GOTERM["GO:0000001"] -## goItem in an instance of an S4 class -## slots can be accessed as Python attributes -goItem.Term Property changes on: rpy2/trunk/doc ___________________________________________________________________ Added: svn:mergeinfo + /rpy2/trunk/doc:691-700,702 Modified: rpy2/trunk/doc/source/conf.py =================================================================== --- rpy2/trunk/doc/source/conf.py 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/doc/source/conf.py 2008-12-03 12:09:01 UTC (rev 712) @@ -45,8 +45,8 @@ # The short X.Y version. version = '2.0' # The full version, including alpha/beta/rc tags. -release = '2.0.0dev' -releaselevel = 'dev' +release = '2.0.0' +releaselevel = '' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: Modified: rpy2/trunk/doc/source/index.rst =================================================================== --- rpy2/trunk/doc/source/index.rst 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/doc/source/index.rst 2008-12-03 12:09:01 UTC (rev 712) @@ -9,6 +9,7 @@ introduction robjects numpy + robjects_convert rinterface rpy_classic rlike Modified: rpy2/trunk/doc/source/overview.rst =================================================================== --- rpy2/trunk/doc/source/overview.rst 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/doc/source/overview.rst 2008-12-03 12:09:01 UTC (rev 712) @@ -208,4 +208,7 @@ of the implementation questions were found there. Contributors - Their names are in Section Changes. + The help of people, donating time, ideas or software patches + is much appreciated. + Their names can be found in this documentation (mostly around the + section Changes). Modified: rpy2/trunk/doc/source/robjects.rst =================================================================== --- rpy2/trunk/doc/source/robjects.rst 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/doc/source/robjects.rst 2008-12-03 12:09:01 UTC (rev 712) @@ -518,69 +518,3 @@ fit = robjects.r('lm(%s)' %fmla.r_repr()) - -Mapping rpy2 objects to arbitrary python objects -===================================================== - -The conversion, often present when working with RPy-1.x, is no longer -necessary as the R objects can be either passed on to R functions -or used in Python. - -However, there is a low-level mapping between `R` and `Python` objects -performed behind the (Python-level) scene, done by the :mod:`rpy2.rinterface`, -while an higher-level mapping is done between low-level objects and -higher-level objects using the functions: - -:meth:`conversion.ri2py` - :mod:`rpy2.rinterface` to Python. By default, this function - is just an alias for the function :meth:`default_ri2py`. - -:meth:`conversion.py2ri` - Python to :mod:`rpy2.rinterface`. By default, this function - is just an alias for the function :meth:`default_py2ri`. - -:meth:`conversion.py2ro` - Python to :mod:`rpy2.robjects`. By default, that one function - is merely a call to :meth:`conversion.py2ri` - followed by a call to :meth:`conversion.ri2py`. - -Those functions can be re-routed to satisfy all requirements, with -the easiest option being to write a custom function calling itself -the default functions. - -Switching to `numpy`-to-`rpy2` is using this mechanism. - -As an example, let's assume that one want to return atomic values -whenever an R numerical vector is of length one. This is only a matter -of writing a new function `ri2py` that handles this, as shown below: - -.. code-block:: python - - import rpy2.robjects as robjects - - def my_ri2py(obj): - res = robjects.default_ri2py(obj) - if isinstance(res, robjects.RVector) and (len(res) == 1): - res = res[0] - return res - - robjects.conversion.ri2py = my_ri2py - -Once this is done, we can verify immediately that this is working with: - ->>> pi = robjects.r.pi ->>> type(pi) -<type 'float'> ->>> - -The default behavior can be restored with: - ->>> robjects.conversion.ri2py = default_ri2py - -The docstrings for :meth:`default_ri2py`, :meth:`default_py2ri`, and :meth:`py2ro` are: - -.. autofunction:: rpy2.robjects.default_ri2py -.. autofunction:: rpy2.robjects.default_py2ri -.. autofunction:: rpy2.robjects.default_py2ro - - Copied: rpy2/trunk/doc/source/robjects_convert.rst (from rev 711, rpy2/branches/version_2.0.x/doc/source/robjects_convert.rst) =================================================================== --- rpy2/trunk/doc/source/robjects_convert.rst (rev 0) +++ rpy2/trunk/doc/source/robjects_convert.rst 2008-12-03 12:09:01 UTC (rev 712) @@ -0,0 +1,71 @@ + +Mapping rpy2 objects to arbitrary python objects +===================================================== + +Switching between a conversion and a no conversion mode, +an operation often present when working with RPy-1.x, is no longer +necessary as the R objects can be either passed on to R functions +or used in Python. + +However, there is a low-level mapping between `R` and `Python` objects +performed behind the (Python-level) scene, done by the :mod:`rpy2.rinterface`, +while an higher-level mapping is done between low-level objects and +higher-level objects using the functions: + +:meth:`conversion.ri2py` + :mod:`rpy2.rinterface` to Python. By default, this function + is just an alias for the function :meth:`default_ri2py`. + +:meth:`conversion.py2ri` + Python to :mod:`rpy2.rinterface`. By default, this function + is just an alias for the function :meth:`default_py2ri`. + +:meth:`conversion.py2ro` + Python to :mod:`rpy2.robjects`. By default, that one function + is merely a call to :meth:`conversion.py2ri` + followed by a call to :meth:`conversion.ri2py`. + +Those functions can be re-routed to satisfy all requirements, with +the easiest option being to write a custom function calling itself +the default function when the custom conversion should not apply. + +A simple example +---------------- + +As an example, let's assume that one want to return atomic values +whenever an R numerical vector is of length one. This is only a matter +of writing a new function `ri2py` that handles this, as shown below: + +.. code-block:: python + + import rpy2.robjects as robjects + + def my_ri2py(obj): + res = robjects.default_ri2py(obj) + if isinstance(res, robjects.RVector) and (len(res) == 1): + res = res[0] + return res + + robjects.conversion.ri2py = my_ri2py + +Once this is done, we can verify immediately that this is working with: + +>>> pi = robjects.r.pi +>>> type(pi) +<type 'float'> +>>> + +The default behavior can be restored with: + +>>> robjects.conversion.ri2py = default_ri2py + +Default functions +----------------- + +The docstrings for :meth:`default_ri2py`, :meth:`default_py2ri`, and :meth:`py2ro` are: + +.. autofunction:: rpy2.robjects.default_ri2py +.. autofunction:: rpy2.robjects.default_py2ri +.. autofunction:: rpy2.robjects.default_py2ro + + Modified: rpy2/trunk/rpy/__init__.py =================================================================== --- rpy2/trunk/rpy/__init__.py 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/rpy/__init__.py 2008-12-03 12:09:01 UTC (rev 712) @@ -1,2 +1 @@ __version__ = '2.1.0dev' - Modified: rpy2/trunk/rpy/rinterface/__init__.py =================================================================== --- rpy2/trunk/rpy/rinterface/__init__.py 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/rpy/rinterface/__init__.py 2008-12-03 12:09:01 UTC (rev 712) @@ -1,7 +1,7 @@ import os, sys try: - R_HOME = os.environ["R_HOME"] + R_HOME = (os.environ["R_HOME"], ) except KeyError: R_HOME = os.popen("R RHOME").readlines() Modified: rpy2/trunk/setup.py =================================================================== --- rpy2/trunk/setup.py 2008-12-03 11:40:00 UTC (rev 711) +++ rpy2/trunk/setup.py 2008-12-03 12:09:01 UTC (rev 712) @@ -4,6 +4,7 @@ pack_name = 'rpy2' + pack_version = '2.1.0dev' RHOMES = os.getenv('RHOMES') 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