Unclear documentation on how to activate numpy2ri

Issue #257 resolved
alimanfoo
created an issue

Using rpy2==2.5.4.

The documentation says that to activate automatic conversion of numpy objects to R, do the following:

from rpy2.robjects.numpy2ri import numpy2ri
ro.conversion.py2ri = numpy2ri

However, I found that this does not correctly activate the conversions, leading to non-numpy objects ending up in the numpy2ri function, raising an AttributeError when the function tries to access a dtype property that isn't there.

If however I do the following:

import rpy2.robjects.numpy2ri as numpy2ri
numpy2ri.activate()

...everything seems to work OK.

Suggesting making the documentation clear about the correct way to activate the numpy conversion.

Comments (7)

  1. Jonathan Taylor

    I am having problems with several different python modules that want to use a function of R here and there.

    Should we activate and deactivate with each call to R? Are multiple calls to activate a problem? Should we deactivate at exit?

  2. Log in to comment