[Rpy] SF.net SVN: rpy: [459] branches/rpy_nextgen/rpy/robjects/__init__.py

2008-03-23 Thread lgautier
Revision: 459
  http://rpy.svn.sourceforge.net/rpy/?rev=459&view=rev
Author:   lgautier
Date: 2008-03-23 04:10:21 -0700 (Sun, 23 Mar 2008)

Log Message:
---
- added __setitem__
- added object globalEnv

Modified Paths:
--
branches/rpy_nextgen/rpy/robjects/__init__.py

Modified: branches/rpy_nextgen/rpy/robjects/__init__.py
===
--- branches/rpy_nextgen/rpy/robjects/__init__.py   2008-03-22 14:04:19 UTC 
(rev 458)
+++ branches/rpy_nextgen/rpy/robjects/__init__.py   2008-03-23 11:10:21 UTC 
(rev 459)
@@ -184,6 +184,10 @@
 res = mapperR2Py(res)
 return res
 
+def __setitem__(self, item, value):
+robj = mapperPy2R(value)
+self._sexp[item] = robj._sexp
+
 class RS4(Robject):
 def __init__(self, o):
 if (isinstance(o, rinterface.SexpS4)):
@@ -228,4 +232,5 @@
 
 r = R(["--no-save", "--quiet"])
 
+globalEnv = mapperR2Py(rinterface.globalEnv)
 


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/vse012070mrt/direct/01/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


[Rpy] SF.net SVN: rpy: [460] branches/rpy_nextgen

2008-03-23 Thread lgautier
Revision: 460
  http://rpy.svn.sourceforge.net/rpy/?rev=460&view=rev
Author:   lgautier
Date: 2008-03-23 04:10:57 -0700 (Sun, 23 Mar 2008)

Log Message:
---
Documentation: first stab

Added Paths:
---
branches/rpy_nextgen/doc/
branches/rpy_nextgen/doc/rpy.texi

Added: branches/rpy_nextgen/doc/rpy.texi
===
--- branches/rpy_nextgen/doc/rpy.texi   (rev 0)
+++ branches/rpy_nextgen/doc/rpy.texi   2008-03-23 11:10:57 UTC (rev 460)
@@ -0,0 +1,542 @@
+\input texinfo  @c -*-texinfo-*-
+
[EMAIL PROTECTED] %**start of header
[EMAIL PROTECTED] rpy.info
[EMAIL PROTECTED] @RPy{} Reference Manual
[EMAIL PROTECTED] %**end of header
[EMAIL PROTECTED] Programming
[EMAIL PROTECTED]
+* RPy v2: (rpy2).   RPy2, Python extension module for R.
[EMAIL PROTECTED] direntry
+
[EMAIL PROTECTED] version
+2.0.0-dev
[EMAIL PROTECTED] macro
+
[EMAIL PROTECTED] Python
+Python
[EMAIL PROTECTED] macro
+
[EMAIL PROTECTED] RPy
+RPy
[EMAIL PROTECTED] macro
[EMAIL PROTECTED] RPy2
+RPy2
[EMAIL PROTECTED] macro
+
[EMAIL PROTECTED] R
+R
[EMAIL PROTECTED] macro
+
[EMAIL PROTECTED] C
+C
[EMAIL PROTECTED] macro
+
[EMAIL PROTECTED]
+This file documents @RPy2{} @version{}
+
+Copyright -
+Permission is granted to make and distribute verbatim
+copies of this manual provided the copyright notice and
+this permission notice are preserved on all copies.
+
[EMAIL PROTECTED]
+Permission is granted to process this file through TeX
+and print the results, provided the printed document
+carries a copying permission notice identical to this
+one except for the removal of this paragraph (this
+paragraph not being relevant to the printed manual).
[EMAIL PROTECTED] ignore
+
+Permission is granted to copy and distribute modified
+versions of this manual under the conditions for
+verbatim copying, provided also that the sections
+entitled ``Copying'' and ``GNU General Public License''
+are included exactly as in the original, and provided
+that the entire resulting derived work is distributed
+under the terms of a permission notice identical to this
+one.
+
+Permission is granted to copy and distribute
+translations of this manual into another language,
+under the above conditions for modified versions,
+except that this permission notice may be stated in a
+translation approved by the Free Software Foundation.
[EMAIL PROTECTED] ifinfo
+
[EMAIL PROTECTED]
[EMAIL PROTECTED] @RPy2{} Reference Manual
[EMAIL PROTECTED] (version @version{})
[EMAIL PROTECTED] Laurent Gautier
[EMAIL PROTECTED]
[EMAIL PROTECTED] 0pt plus 1filll
+Copyright @copyright{} 2008
+
+Permission is granted to make and distribute verbatim copies of this
+manual provided the copyright notice and this permission notice are
+preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided also that
+the sections entitled ``Copying'' and ``GNU General Public License''
+are included exactly as in the original, and provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be stated in a
+translation approved by the Free Software Foundation.
[EMAIL PROTECTED] titlepage
+
[EMAIL PROTECTED]
[EMAIL PROTECTED] Top, Overview, (dir), (dir)
[EMAIL PROTECTED] @RPy{} Reference Manual (version @version{})
+
+This is the reference manual for @RPy{} version @version{}, a @Python{}
+extension module for using the @R{} programming language.
[EMAIL PROTECTED] ifnottex
+
[EMAIL PROTECTED]
+* Preface::
+* Overview::
+* robjects::
+* rinterface::
+* Acknowledgements::
[EMAIL PROTECTED] menu
+
+
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED] iftex
+
[EMAIL PROTECTED] Preface, Overview, , Top
[EMAIL PROTECTED] Preface
+
+This presentation describes @RPy2{}, a close-to-complete rewrite of
+the @RPy{} package.
+
+It is developped for R-2.7 (and is not expected to work
+with a previous version), together with @Python{} 2.5. Compatibility
+with @Python{} 2.4 is expected but not tested when writing
+those lines.
+
+The contributed code of Alexander Belopolsky, who contributed
+a rewrite to @RPy{} is acknowledged.
+The original work of Walter Moreira, and Gregory Warnes, is also
+acknowledged here.
+
+
[EMAIL PROTECTED] Overview, , Preface, Top
[EMAIL PROTECTED] Overview
+
+
[EMAIL PROTECTED]://www.python.org, @Python{}} is a popular 
+all-purpose scripting language, while @uref{http://www.r-project.org, @R{}}
+is a scripting language mostly popular for data analysis, statistics, and
+graphics.
+
+
+The @RPy{} project is an effort to have access to @R{} from within @Python{}, 
+
+The @RPy{} code is initially inspired in RSPython, which is part of
+t

[Rpy] SF.net SVN: rpy: [461] branches/rpy_nextgen/rpy

2008-03-23 Thread lgautier
Revision: 461
  http://rpy.svn.sourceforge.net/rpy/?rev=461&view=rev
Author:   lgautier
Date: 2008-03-23 04:20:29 -0700 (Sun, 23 Mar 2008)

Log Message:
---
Proper running of *all* unit tests when running rpy_nextgen/rpy/tests.py

Modified Paths:
--
branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVector.py
branches/rpy_nextgen/rpy/tests.py

Modified: branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVector.py
===
--- branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVector.py
2008-03-23 11:10:57 UTC (rev 460)
+++ branches/rpy_nextgen/rpy/rinterface/tests/test_SexpVector.py
2008-03-23 11:20:29 UTC (rev 461)
@@ -164,9 +164,8 @@
 
 def testAssignItemString(self):
 letters_R = rinterface.globalEnv.get("letters")
-#FIXME: segfaults
 #letters_R[0] = rinterface.SexpVector(["z", ], rinterface.STRSXP)
-self.assertTrue(letters_R[0] == "z")
+self.assertTrue(letters_R[0] == "z") #FIXME: segfault when assigning 
value
 
 def suite():
 suite = unittest.TestLoader().loadTestsFromTestCase(SexpVectorTestCase)

Modified: branches/rpy_nextgen/rpy/tests.py
===
--- branches/rpy_nextgen/rpy/tests.py   2008-03-23 11:10:57 UTC (rev 460)
+++ branches/rpy_nextgen/rpy/tests.py   2008-03-23 11:20:29 UTC (rev 461)
@@ -6,7 +6,7 @@
 def suite():
 suite_robjects = rpy2.robjects.tests.suite()
 suite_rinterface = rpy2.rinterface.tests.suite()
-alltests = unittest.TestSuite([suite_robjects, ])
+alltests = unittest.TestSuite([suite_robjects, suite_rinterface])
 return alltests
 
 if __name__ == "__main__":


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/vse012070mrt/direct/01/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


[Rpy] SF.net SVN: rpy: [462] branches/rpy_nextgen/setup.py

2008-03-23 Thread lgautier
Revision: 462
  http://rpy.svn.sourceforge.net/rpy/?rev=462&view=rev
Author:   lgautier
Date: 2008-03-23 15:03:51 -0700 (Sun, 23 Mar 2008)

Log Message:
---
R_HOME trouble at compile time was not properly fixed :/

Modified Paths:
--
branches/rpy_nextgen/setup.py

Modified: branches/rpy_nextgen/setup.py
===
--- branches/rpy_nextgen/setup.py   2008-03-23 11:20:29 UTC (rev 461)
+++ branches/rpy_nextgen/setup.py   2008-03-23 22:03:51 UTC (rev 462)
@@ -9,11 +9,12 @@
 RHOMES = os.getenv('RHOMES')
 
 if RHOMES is None:
-RHOMES = [Popen(["R", "RHOME"], stdout=PIPE).communicate()[0].strip(), ]
+RHOMES = Popen(["R", "RHOME"], stdout=PIPE).communicate()[0].strip()
 #Twist if 'R RHOME' spits out a warning
-if RHOMES[:6] == "WARNING":
-i = s.find(os.linesep)
+if RHOMES.startswith("WARNING"):
+i = RHOMES.find(os.linesep)
 RHOMES = RHOMES[i:]
+RHOMES = [RHOMES, ]
 else:
 RHOMES = RHOMES.split(os.pathsep)
 


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/vse012070mrt/direct/01/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


[Rpy] SF.net SVN: rpy: [463] branches/rpy_nextgen/rpy/rinterface

2008-03-23 Thread lgautier
Revision: 463
  http://rpy.svn.sourceforge.net/rpy/?rev=463&view=rev
Author:   lgautier
Date: 2008-03-23 15:08:42 -0700 (Sun, 23 Mar 2008)

Log Message:
---
Implemented "len()" for SexpEnvironment

Modified Paths:
--
branches/rpy_nextgen/rpy/rinterface/rinterface.c
branches/rpy_nextgen/rpy/rinterface/tests/test_SexpEnvironment.py

Modified: branches/rpy_nextgen/rpy/rinterface/rinterface.c
===
--- branches/rpy_nextgen/rpy/rinterface/rinterface.c2008-03-23 22:03:51 UTC 
(rev 462)
+++ branches/rpy_nextgen/rpy/rinterface/rinterface.c2008-03-23 22:08:42 UTC 
(rev 463)
@@ -168,6 +168,8 @@
 
   globalEnv->sexp = R_GlobalEnv;
 
+  baseNameSpaceEnv->sexp = R_BaseNamespace;
+
   PyObject *res = PyInt_FromLong(status);
 
   return res;
@@ -1008,14 +1010,24 @@
   return 0;
 }
 
+static Py_ssize_t EnvironmentSexp_length(PyObject *self) 
+{
+  SEXP rho_R = ((SexpObject *)self)->sexp;
+  if (! rho_R) {
+PyErr_Format(PyExc_ValueError, "The environment has NULL SEXP.");
+return -1;
+  }
+  SEXP symbols = R_lsInternal(rho_R, TRUE);
+  Py_ssize_t len = (Py_ssize_t)GET_LENGTH(symbols);
+  return len;
+}
+
 static PyMappingMethods EnvironmentSexp_mappignMethods = {
-  0, /* mp_length */
+  (lenfunc)EnvironmentSexp_length, /* mp_length */
   (binaryfunc)EnvironmentSexp_subscript, /* mp_subscript */
   (objobjargproc)EnvironmentSexp_ass_subscript  /* mp_ass_subscript */
 };
 
-//FIXME: write more doc - should the environments
-// be made like mappings at the Python level ?
 PyDoc_STRVAR(EnvironmentSexp_Type_doc,
 "R object that is an environment.\
  R environments can be seen as similar to Python\

Modified: branches/rpy_nextgen/rpy/rinterface/tests/test_SexpEnvironment.py
===
--- branches/rpy_nextgen/rpy/rinterface/tests/test_SexpEnvironment.py   
2008-03-23 22:03:51 UTC (rev 462)
+++ branches/rpy_nextgen/rpy/rinterface/tests/test_SexpEnvironment.py   
2008-03-23 22:08:42 UTC (rev 463)
@@ -45,6 +45,15 @@
 a = rinterface.globalEnv["a"]
 self.assertTrue(False) #FIXME: write proper unit test here
 
+def testLength(self):
+newEnv = rinterface.globalEnv.get("new.env")
+env = newEnv()
+self.assertEquals(0, len(env))
+env["a"] = rinterface.SexpVector([123, ], rinterface.INTSXP)
+self.assertEquals(1, len(env))
+env["b"] = rinterface.SexpVector([123, ], rinterface.INTSXP)
+self.assertEquals(2, len(env))
+
 def suite():
 suite = 
unittest.TestLoader().loadTestsFromTestCase(SexpEnvironmentTestCase)
 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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list