[Numpy-discussion] Recarray and shared datas

Sasha ndarray at mac.com
Mon Apr 10 19:46:00 EDT 2006


This thread probably belongs to rpy-list, so I'll cross-post.

I may be wrong, but I think R data frames are stored column-wise
unlike recarrays. This also means that data sharing between R and
numpy is feasible even without recarrays.

RPy support for doing this should probably wait until RPy 2.0 when R
objects become wrapped in a Python type.  That type will need to
provide __array_struct__ interface to allow data sharing.

NA data handling in numpy is a topic of an active discussion now.  A
numpy array with data shared with an R vector will see NAs differently
for different types.  For ints, it will be INT_MIN (-2^31 on 32-bit
machines), for floats it will be a NaN with some special bit-pattern
in the mantissa and thus not fully compatible with numpy's nan.

I would like to use this cross-post as an opportunily to invite RPy
users to participate in numpy's discussion of missing (or masked)
values.  See "ndarray.fill and ma.array.filled" thread.

On 4/10/06, Michael Sorich <michael.sorich at gmail.com> wrote:
> On 4/6/06, Benjamin Thyreau <benjamin at decideur.info> wrote:
>
> > Hi,
> > Numpy has a nice feature of recarray, ie. record which can hold columns
> names.
> > I'd like to use such a feature in order to better interact with R, ie.
> passing
> > R datas to python without copy. The current rpy bindings do a full copy,
> and
> > convert to simple ndarray. Looking at the recarray api in the Guide,
> > and also at the source code, i don't find any recarray constructor which
> can
> > get shared datas (all the examples from section 8.6 are doing copies).
> > Is there some way to do it ? in Python or in C ? Or is there any plans to
> ?
>
>
> As a current user of rpy  (at least until I can easily do the equivalent in
> numpy/scipy) this sound very interesting. What will happen if the R
> data.frame has NA data? I don't think the recarray can currently handle
> masked data. Oh well, one step forward at a time. Good luck.
>
> Mike
>
>
>




More information about the NumPy-Discussion mailing list