[Rpy] [patch] rpy2 tip broken on Unix systems

2009-02-08 Thread Nathaniel Smith
I tracked down that strange "unresolved symbol" error I was getting. It turns out that rpy2 tip includes a reference to R_ProcessEvents unconditionally, but in fact R_ProcessEvents is not a portable API. R_ProcessEvents only exists on Win32 and OS X/Aqua builds of R. And on OS X, unless someone ha

[Rpy] [patch] expose R_MissingArg

2009-02-08 Thread Nathaniel Smith
There are several times in R when it is valuable to explicitly leave an argument missing. For example, when extracting a row from a matrix: > m <- matrix(1:4, nrow=2) > m[2] # Flat indexing [1] 2 > m[2, ] # Note the comma! [1] 2 4 However, there is currently no way to support this (rather idios

[Rpy] [patch] expose Rf_duplicate

2009-02-08 Thread Nathaniel Smith
The attached patch adds a method ".duplicate" to rinterface.Sexp objects. When called, it returns a new Sexp that is identical to the first, but shares no memory with the first. (Underlyingly, it just calls Rf_duplicate.) This is useful when you have an Sexp that you want to mutate, but you also w

Re: [Rpy] [patch] misc cleanups

2009-02-08 Thread Nathaniel Smith
On Sun, Feb 8, 2009 at 1:40 AM, Nathaniel Smith wrote: > This patch just cleans up a few things I noticed while hacking: > - The testSexp_sexp_destroyCobj test is a no-op. I'm not sure what > it's trying to test, but whatever it is, it isn't testing it. > - Fix most compile warnings that occur w

[Rpy] [patch] misc cleanups

2009-02-08 Thread Nathaniel Smith
This patch just cleans up a few things I noticed while hacking: - The testSexp_sexp_destroyCobj test is a no-op. I'm not sure what it's trying to test, but whatever it is, it isn't testing it. - Fix most compile warnings that occur when building rinterface.c The remaining build warning I get is:

Re: [Rpy] [patch] rpy2 tip broken on Unix systems

2009-02-08 Thread Laurent Gautier
Nathaniel Smith wrote: > I tracked down that strange "unresolved symbol" error I was getting. > It turns out that rpy2 tip includes a reference to R_ProcessEvents > unconditionally, but in fact R_ProcessEvents is not a portable API. > R_ProcessEvents only exists on Win32 and OS X/Aqua builds of R.

Re: [Rpy] [patch] expose R_MissingArg

2009-02-08 Thread Laurent Gautier
Nathaniel Smith wrote: > There are several times in R when it is valuable to explicitly leave > an argument missing. For example, when extracting a row from a matrix: > >> m <- matrix(1:4, nrow=2) >> m[2] # Flat indexing > [1] 2 >> m[2, ] # Note the comma! > [1] 2 4 > > However, there is curren

Re: [Rpy] rpy2 design questions

2009-02-08 Thread Laurent Gautier
Michael Held wrote: > hi folks, > > coming from rpy I was wondering why rpy2 is trying to make so much > overhead. I was used to a convenient way of using R from Python, but the > use of robjects.FloatVector([]) and co in rpy2 is blowing up my code. > what is the reason for that? The choice rpy2.

Re: [Rpy] [patch] numpy.asarray(SexpVector([...], LGLSXP)) fails

2009-02-08 Thread Laurent Gautier
Thanks for your patch. I had to replace in test_SexpVectorNumeric.py nx.typecode() by nx.dtype.kind I am not using numpy as much as as use other packages, but I think that typecode() was coming from Numeric and is disappearing. I am patching the tip, and will likely backport this to the branch

Re: [Rpy] [patch] expose Rf_duplicate

2009-02-08 Thread Laurent Gautier
Nice. What about calling the method __copy__ instead (so it fits other Python objects) ? L. Nathaniel Smith wrote: > The attached patch adds a method ".duplicate" to rinterface.Sexp > objects. When called, it returns a new Sexp that is identical to the > first, but shares no memory with the fi

Re: [Rpy] [patch] rpy2 tip broken on Unix systems

2009-02-08 Thread Laurent Gautier
It turned out that a stale PYTHONPATH was getting an older version of rpy2 when running it on my end. So much for the cross-platform unifying bit. :/ Now the tip should build and run on Linux. Thanks for following the bitbucket tip. L. Laurent Gautier wrote: > Nathaniel Smith wrote: >> I trac

Re: [Rpy] [patch] expose Rf_duplicate

2009-02-08 Thread Nathaniel Smith
On Sun, Feb 8, 2009 at 6:13 AM, Laurent Gautier wrote: > Nice. > > What about calling the method __copy__ instead (so it fits other Python > objects) ? I don't really care either way. I guess calling it "duplicate" avoids any question of whether it should be __copy__ or __deepcopy__, but since it

Re: [Rpy] [patch] expose R_MissingArg

2009-02-08 Thread Nathaniel Smith
On Sun, Feb 8, 2009 at 2:22 AM, Laurent Gautier wrote: > In the case of extracting elements from a matrix, there is a way > (working in R, as well as in rpy2): > > m[2, TRUE] # Note the TRUE ! > [1] 2 4 Ah, cute trick, thanks. > I'd be more keen on defining the missing magic, as well as NULL and

Re: [Rpy] [patch] rpy2 tip broken on Unix systems

2009-02-08 Thread Nathaniel Smith
On Sun, Feb 8, 2009 at 2:01 PM, Laurent Gautier wrote: > It turned out that a stale PYTHONPATH was getting an older version of rpy2 > when running it on my end. > So much for the cross-platform unifying bit. :/ > > Now the tip should build and run on Linux. It does work for me, though my internal

[Rpy] [patch] R 2.7 compatibility fix for rpy_device.c

2009-02-08 Thread Nathaniel Smith
I tracked down that build error I've mentioned a few times with the new graphics device code -- it's an R 2.7 vs. R 2.8 compatibility bug. In 2.8, pDevDesc is (DevDesc *), but in 2.7 it's (NewDevDesc *), and so trying to malloc a DevDesc doesn't work in 2.7, you need to malloc a NewDevDesc instead.

[Rpy] [patch] allow do_slot_assign to create new attributes

2009-02-08 Thread Nathaniel Smith
Currently, the following generates an exception: >>> s = ri.SexpVector([1, 2, 3, 4], ri.INTSXP) >>> s.do_slot_assign("dim", ri.SexpVector([2, 2], ri.INTSXP) The issue is that s has no "dim" attribute to start off with, and do_slot_assign's implementation checks R_has_slot and errors out if it ret