You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize this library is a prototype, and not that actively maintained (per #5). However I'm really glad it's here as more and more R libraries use R6 classes and there is occasionally (frequently in my case) a need to port these to Python.
I have an example of a Model class (implemented as an R6 class) which has a method that returns a ModelFit class (separate R6 class). Each class works really well on its own. The problem comes when I try to use the ModelFit returned by a method implemented in the Model class (generated in R), rather than one I created in Python.
To be more concrete, let's say I run the following:
It is hard to be certain without more details about the implementation of your Python class TSModel. However, r6a and r6b are 2 different approaches to map R6 to Python. r6b is trying to dynamically create Python classes to match the R6 classes. What you worked out should be fine. The meta-programming in r6b might be trying be too clever for its own good.
If you followed this to get TSModel, the method fit was created dynamically by looking at the R6 class definition. However, there is currently no dynamic inference of the return type mapped to an rpy2_r6.r6b class (and I am not sure that it is possible to achieve this).
mod.fit() returns an Environment because R6 instances are R environment objects and r6b does not connect those dots yet.
If you want to stay with r6b all the way, the following might work:
# Assumes that the R6 class definition for `TSModelFit` is in `your_r_package`.TSModelFit=r6b.R6DynamicClassGenerator(your_r_package.TSModelFit)
TSModelFit.__R6CLASS__(mod.fit)
Hi,
I realize this library is a prototype, and not that actively maintained (per #5). However I'm really glad it's here as more and more R libraries use R6 classes and there is occasionally (frequently in my case) a need to port these to Python.
I have an example of a Model class (implemented as an R6 class) which has a method that returns a ModelFit class (separate R6 class). Each class works really well on its own. The problem comes when I try to use the ModelFit returned by a method implemented in the Model class (generated in R), rather than one I created in Python.
To be more concrete, let's say I run the following:
At this point, the Model object has a class
rpy2_r6.r6b.TSModel
whereas the ModelFit object has a classrpy2.robjects.environments.Environment
:Is there a way to turn this
fit
object into something of therpy2_r6.r6b.TSModelFit
class? Or, to do it analogously using ther6a
formulation?The text was updated successfully, but these errors were encountered: