-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* IJulia docstrings * macro docstrings * remove some shadowing * tests for IJulia * get coverage * more coverage * linux only * headless * set up jupyter kernel
- Loading branch information
Showing
8 changed files
with
154 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ijulia.html | ||
ijulia.ipynb | ||
ijulia-checkpoint*.ipynb | ||
ijulia_files/ | ||
ijulia.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Conda | ||
using IJulia | ||
using RCall | ||
using Weave | ||
using Test | ||
|
||
# $(abspath(dirname(@__DIR__))) | ||
IJulia.installkernel("julia", "--project=@.") | ||
jupyter_path = joinpath(Conda.BINDIR, "jupyter") | ||
if !isfile(jupyter_path) | ||
Conda.add("jupyter") | ||
end | ||
testpath = Base.Fix1(joinpath, @__DIR__) | ||
Weave.notebook(testpath("ijulia.jmd"); out_path=@__DIR__, jupyter_path=jupyter_path) | ||
|
||
run(`$(jupyter_path) nbconvert $(testpath("ijulia.ipynb")) --to html --embed-images`) | ||
const PNG = """<img alt="No description has been provided for this image" class="" src="data:image/png;base64""" | ||
const SVG = """<img alt="No description has been provided for this image" src="data:image/svg+xml;base64""" | ||
html = read(testpath("ijulia.html"), String) | ||
|
||
# these are the tests to show that things actually work | ||
@test occursin(PNG, html) | ||
@test occursin(SVG, html) | ||
|
||
@test_throws ArgumentError("Unsupported MIME type: lulz") RCall.rdevicename(MIME("lulz")) | ||
|
||
# create a folder ijulia_files with the exported images -- could be useful if we ever set up percy | ||
# run(`$(jupyter_path) nbconvert $(testpath("ijulia.ipynb")) --to markdown`) | ||
|
||
# these are the tests to get code coverage | ||
# nothing like a little piracy when testing in a headless setup | ||
RCall.ijulia_init() | ||
R"plot(1:10, 1:10)" | ||
# throws a method error when running headless ! | ||
@test_throws(MethodError, RCall.ijulia_displayplots()) | ||
RCall.ijulia_setdevice(MIME("image/svg+xml")) | ||
R"plot(-1 * 1:10, -1 * 1:10)" | ||
# throws a method error when running headless ! | ||
@test_throws(MethodError, RCall.ijulia_displayplots()) | ||
RCall.ijulia_cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
```julia | ||
using RCall | ||
RCall.ijulia_init() | ||
R"plot(1:10, 1:10)" | ||
``` | ||
|
||
```julia | ||
RCall.ijulia_setdevice(MIME("image/svg+xml")) | ||
R"plot(-1 * 1:10, -1 * 1:10)" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters