On Monday, June 6, 2011 12:55:49 PM UTC-7, kcrisman wrote:
>
>
> >
> > > So I feel like pexpect must be doing something naughty. Does anyone
> > > have any ideas what might be going on so I can use more data?
> >
> > I tried this experiment: I added spaces to the first string to be
> > evaluated. When the string has length <= 1024, it seems to work, and
> when
> > the string has length > 1024, it doesn't. For example:
> >
> > sage: s = 'matrix(c(1, 1, 1, 1,' + ' '*987 + '2,2,2,2), ncol=4)'
> > sage: len(s)
> > 1024
> > sage: r.eval(s)
> > ' [,1] [,2] [,3] [,4]\n[1,] 1 1 2 2\n[2,] 1 1
>
> > 2 2'
> > sage: s = 'matrix(c(1, 1, 1, 1,' + ' '*988 + '2,2,2,2), ncol=4)'
> > sage: len(s)
> > 1025
> > sage: r.eval(s)
> > ''
> >
> > I don't know why, but maybe that can help you track it down.
>
> Thanks - that definitely helps, since pexpect is actually passing
> strings.
Well, searching for "1024" in r.py results in two hits, and I think the
relevant one is
# If an input is longer than this number of characters,
then
# try to switch to outputting to a file.
eval_using_file_cutoff=1024)
If you input a string longer than 1024 characters, it writes it to a file
and then tries to read that file. It looks to me as though the method
_read_in_file_command in r.py isn't doing the right thing: the correct
string is getting written to the correct file, but then it's not getting
imported properly. That is, in expect.py, it's executing this code:
try:
s = self._eval_line(self._read_in_file_command(tmp_to_use),
allow_use_file=False)
and it's returning an empty string, even though tmp_to_use is set to the
correct file name and that file has the correct contents. I don't know R
syntax, so I don't know what's going wrong.
--
John
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org