Revision: 553 http://rpy.svn.sourceforge.net/rpy/?rev=553&view=rev Author: lgautier Date: 2008-06-08 00:36:11 -0700 (Sun, 08 Jun 2008)
Log Message: ----------- robjects: - fixed order of inheritance of RObjectMixin - use method do_slot (rather than evalute "@") - old name was left behind in test Modified Paths: -------------- branches/rpy_nextgen/rpy/robjects/__init__.py branches/rpy_nextgen/rpy/robjects/tests/testRobjects.py Modified: branches/rpy_nextgen/rpy/robjects/__init__.py =================================================================== --- branches/rpy_nextgen/rpy/robjects/__init__.py 2008-06-07 21:26:40 UTC (rev 552) +++ branches/rpy_nextgen/rpy/robjects/__init__.py 2008-06-08 07:36:11 UTC (rev 553) @@ -17,7 +17,11 @@ if isinstance(o, RObject): res = o elif isinstance(o, rinterface.SexpVector): - res = RVector(o) + try: + dim = o.do_slot("dim") + res = RArray(o) + except LookupError, le: + res = RVector(o) elif isinstance(o, rinterface.SexpClosure): res = RFunction(o) elif isinstance(o, rinterface.SexpEnvironment): @@ -90,17 +94,11 @@ def __repr__(self): return repr_robject(self) - def typeof(self): - return super(rinterface.Sexp, self).typeof() - - def do_slot(self, name): - return super(rinterface.Sexp, self).do_slot(name) - def rclass(self): return baseNameSpaceEnv["class"](self) -class RObject(rinterface.Sexp, RObjectMixin): +class RObject(RObjectMixin, rinterface.Sexp): def __setattr__(self, name, value): if name == '_sexp': if not isinstance(value, rinterface.Sexp): @@ -111,7 +109,7 @@ -class RVector(rinterface.SexpVector, RObjectMixin): +class RVector(RObjectMixin, rinterface.SexpVector): """ R vector-like object. Items in those instances can be accessed with the method "__getitem__" ("[" operator), or with the method "subset".""" @@ -218,7 +216,7 @@ -class RFunction(rinterface.SexpClosure, RObjectMixin): +class RFunction(RObjectMixin, rinterface.SexpClosure): """ An R function (aka "closure"). """ @@ -232,10 +230,8 @@ res = ri2py(res) return res - #def getSexp(self): - # return super(rinterface.SexpClosure, self).__init__(self) -class REnvironment(rinterface.SexpEnvironment, RObjectMixin): +class REnvironment(RObjectMixin, rinterface.SexpEnvironment): """ An R environement. """ def __init__(self, o=None): @@ -257,10 +253,10 @@ res = ri2py(res) return res -class RS4(rinterface.SexpS4, RObjectMixin): +class RS4(RObjectMixin, rinterface.SexpS4): def __getattr__(self, attr): - res = r.get("@")(self, attr) + res = self.do_slot(attr) return res Modified: branches/rpy_nextgen/rpy/robjects/tests/testRobjects.py =================================================================== --- branches/rpy_nextgen/rpy/robjects/tests/testRobjects.py 2008-06-07 21:26:40 UTC (rev 552) +++ branches/rpy_nextgen/rpy/robjects/tests/testRobjects.py 2008-06-08 07:36:11 UTC (rev 553) @@ -45,7 +45,7 @@ def testMapperR2Python_environment(self): sexp = rinterface.globalEnv.get(".GlobalEnv") self.assertTrue(isinstance(robjects.default_ri2py(sexp), - robjects.Renvironment)) + robjects.REnvironment)) #FIXME: test S4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list