Unclear documentation on how to activate numpy2ri

Issue #257 resolved
Alistair Miles 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

...everything seems to work OK.

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

Comments (7)

  1. Laurent Gautier

    I am happy that you found the big red warning box right below on that exact documentation page that specifies that activation is required.

  2. Laurent Gautier

    Not major in any way: minor edit in the documentation required, but all needed info is otherwise already there.

  3. 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?

  4. Log in to comment