[Numpy-discussion] Patch for RPy to use NumPy uploaded to www.scipy.org
robert.kern at gmail.com
Tue Jan 30 21:38:30 EST 2007
Tim Churches wrote:
> Robert Kern wrote:
>> I don't see why. RPy will use numpy internally to communicate with R. Your code
>> will use Numeric internally to do whatever you do. As of Numeric 24.2, each can
>> consume the other's arrays seamlessly.
> OK, if that is the case, then it might be OK for us if RPy dropped
> Numeric support.
>> You might want to intersperse some
>> Numeric.asarray() and numpy.asarray() calls at the boundaries, but that should
>> be it.
> Ah, so not quite seemless consumption of each other's arrays?
No, that's precisely the consumption that I was referring to. Generally, calling
a function in Numeric on a numpy array will work just fine and vice versa. The
only tricky bit would be code that doesn't "consume" arrays so much as perform
operations on them. For example,
return N.sum(x, axis=0)
f() would work fine with either N=Numeric or N=numpy on Numeric x arrays or
numpy x arrays or indeed lists of numbers or anything else that could be
converted to an array with asarray().
g() would not work with numpy arrays since numpy arrays don't have an
.typecode() method. Of course, neither do lists of numbers and all of the other
various things that a user might pass in hoping that the author programmed
robustly and called asarray().
> We'll need
> to test.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion