Opened 13 years ago
Last modified 4 weeks ago
#7771 needs_work defect
fix R restart in interface
Reported by: | Karl-Dieter Crisman | Owned by: | William Stein |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | interfaces | Keywords: | r-project, R |
Cc: | Merged in: | ||
Authors: | Karl-Dieter Crisman | Reviewers: | Minh Van Nguyen |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
This nearly always happens after installing an R package and then following the directions Sage gives:
sage: r.restart() Error: object 'sage0' not found
This seems to be unrelated to whether R has recommended packages installed or not, so I am making a new ticket for this. Making it minor since just restarting Sage takes care of things as well.
Apply in this order:
Attachments (2)
Change History (17)
comment:1 follow-up: 2 Changed 13 years ago by
comment:2 follow-up: 3 Changed 13 years ago by
Replying to mvngu:
As of Sage 4.3.2.alpha1, ticket #6532 upgrades R to version 2.10.1. From what I gather, after installing an R package, one needs to restart Sage: It didn't say to use the command
r.restart()
.
Yes, that is a change I made since r.restart() didn't work, but in the source it is commented that this should work.
What about issuing
reset()
after installing an R package? It works for me: Perhaps you want the commandr.restart()
to achieve the same effect asexit
andreset()
? That is, one could install an R package withr.install_packages("pkg-name")
, runr.reset()
, and then load the newly installed package withr.library("pkg-name")
?
Maybe; I am not familiar with the reset command. Maybe that is what restart was supposed to do all along? We should ask an R expert.
As a side note, one could not install R packages with a binary Sage distribution.
Oh, that is bad. I wonder why? One can install optional spkgs in a binary install, correct?
comment:3 Changed 13 years ago by
Replying to kcrisman:
Replying to mvngu:
As of Sage 4.3.2.alpha1, ticket #6532 upgrades R to version 2.10.1. From what I gather, after installing an R package, one needs to restart Sage: It didn't say to use the command
r.restart()
.Yes, that is a change I made since r.restart() didn't work, but in the source it is commented that this should work.
Yikes! Turns out that...
## <entry> ## Deprecated in 1.6.0 ## Defunct in 1.7.0 machine <- function() .Defunct() Machine <- function() .Defunct(".Machine") Platform <- function() .Defunct(".Platform") restart <- function() .Defunct("try") ## </entry>
Note that R is now at version 2.10.1! So this is the problem here. The restart() thing must be very old - and odd, since the function that replaced it was try (for exception handling. Anyway, if reset() is good enough, that is fine - no need to do r.foo() if a normal Sage command does it well enough. I'll work on a patch for this.
comment:4 Changed 13 years ago by
In fact, it's not even clear whether one needs to reset().
Please restart Sage in order to use 'igraph'. sage: r.library("igraph") sage: a = r.graph_ring(10) sage: a Vertices: 10 Edges: 10 Directed: FALSE Edges: [0] 0 -- 1 [1] 1 -- 2 [2] 2 -- 3 [3] 3 -- 4 [4] 4 -- 5 [5] 5 -- 6 [6] 6 -- 7 [7] 7 -- 8 [8] 8 -- 9 [9] 0 -- 9 sage: r.add_edges(a, (1,5,2,6) ) Vertices: 10 Edges: 12 Directed: FALSE Edges: [0] 0 -- 1 [1] 1 -- 2 [2] 2 -- 3 [3] 3 -- 4 [4] 4 -- 5 [5] 5 -- 6 [6] 6 -- 7 [7] 7 -- 8 [8] 8 -- 9 [9] 0 -- 9 [10] 1 -- 5 [11] 2 -- 6
And this on an install which definitely hadn't had this package installed before. The same happened with package 'aaMI'. Which leads me to believe one doesn't even have to reset() - the package is just automatically available. I'm going to put up a patch to that effect, with the covering statement to use reset() or restart Sage if you encounter problems.
comment:5 follow-up: 6 Changed 13 years ago by
Authors: | → Karl-Dieter Crisman |
---|---|
Status: | new → needs_review |
This may need slight rebasing after #7665.
comment:6 Changed 13 years ago by
Changed 13 years ago by
Attachment: | trac_7771-reviewer.patch added |
---|
comment:7 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Reviewers: | → Minh Van Nguyen |
With the patch trac_7771-r-restart.patch, I got the following failure when doctesting with "-t -long -optional":
Expected: R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. ... The R package 'aaMI' may now be loaded via r.library('aaMI'). If this should not work, type reset(), or restart Sage. Got: The R package 'aaMI' may now be loaded via r.library('aaMI'). If this should not work, type reset(), or restart Sage.
It might be simpler to just test for the output:
The R package 'aaMI' may now be loaded via r.library('aaMI'). If this should not work, type reset(), or restart Sage.
I have attached a reviewer patch that does only that. With both patches, I now get the following failure:
[mvngu@sage sage-4.4.1]$ ./sage -t -long -optional devel/sage-main/sage/interfaces/r.py sage -t -long -optional "devel/sage-main/sage/interfaces/r.py" <output-trancated> File "/dev/shm/mvngu/sandbox/sage-4.4.1/devel/sage-main/sage/interfaces/r.py", line 1755: sage: latex(r(2)) #optional requires the Hmisc R package Expected: 2 Got: % latex.default(sage12, file = "") % \begin{table}[!tbp] \begin{center} \begin{tabular}{r}\hline\hline \multicolumn{1}{c}{}\tabularnewline \hline $2$\tabularnewline \hline \end{tabular} <BLANKLINE> \end{center} <BLANKLINE> \end{table} <BLANKLINE> ********************************************************************** 1 items had failures: 1 of 3 in __main__.example_67 ***Test Failed*** 1 failures. For whitespace errors, see the file /dev/shm/mvngu/dot_sage/tmp/.doctest_r.py [11.5 s]
But that is for another ticket. So only my patch needs reviewing by anyone but me.
comment:8 Changed 13 years ago by
Status: | needs_review → needs_work |
---|
The above isn't really a problem; it says explicitly that it requires the Hmisc R package, and should be expected to fail unless you have it, which is why it's optional.
The change in the reviewer patch is not okay, though. If R does not start or causes an error, it is silent, but the two print statements will still happen (I just checked this by introducing a typo in the R command). Can you try that again - I assume you were connected to the internet when you tested it, as the optional flag says?
comment:9 Changed 13 years ago by
I see now - you already had loaded Hmisc, and apparently it changed its default Latexing. I can change the patch to fix this.
However, as I said, I still disagree with the reviewer patch. I don't know what to do, though, because apparently doctesting changed and now all things like that loading and downloading happen "before" the actual doctest, at least in how it turns out. I'm not sure what to do about that, because I get the same thing whether I'm connected to the internet or not, which clearly should not be the case for an optional internet doctest! Suggestions?
comment:10 Changed 11 years ago by
Keywords: | r-project R added |
---|
comment:11 Changed 9 years ago by
Milestone: | sage-5.11 → sage-5.12 |
---|
comment:12 Changed 9 years ago by
Milestone: | sage-6.1 → sage-6.2 |
---|
comment:13 Changed 9 years ago by
Milestone: | sage-6.2 → sage-6.3 |
---|
comment:14 Changed 8 years ago by
Milestone: | sage-6.3 → sage-6.4 |
---|
comment:15 Changed 4 weeks ago by
Milestone: | sage-6.4 |
---|
As of Sage 4.3.2.alpha1, ticket #6532 upgrades R to version 2.10.1. From what I gather, after installing an R package, one needs to restart Sage:
It didn't say to use the command
r.restart()
. What about issuingreset()
after installing an R package? It works for me:Perhaps you want the command
r.restart()
to achieve the same effect asexit
andreset()
? That is, one could install an R package withr.install_packages("pkg-name")
, runr.reset()
, and then load the newly installed package withr.library("pkg-name")
? As a side note, one could not install R packages with a binary Sage distribution.