Testing / Dec 13 2019
Viewer Tests
Tests of all the different mime types we support. One test per language, if language supports the mime.
CSV
issue #4535
cp(test2.csv, "/results/test.csv");0.4s
Julia
0 items
using CSVfoo = CSV.read(test2.csv)14.6s
Julia
| A | B | C, D | E | F, | ,G |
|---|---|---|---|---|---|
| 1 | 2 | 3 | 4,3 | 5 | 6 |
| 6 | 5, | 4 | 3 | 2 | ,1 |
2 items
using DataFramesDataFrame(x = rand(10), asjdkasdj = rand(10))0.9s
Julia
| x | asjdkasdj |
|---|---|
| 0.5090136555303661 | 0.8581307495621857 |
| 0.5493630734786932 | 0.5243223862081208 |
| 0.19826415311025736 | 0.7369649352443028 |
| 0.7961218369333276 | 0.00839228128899161 |
| 0.04185752896461814 | 0.11437833360214111 |
| 0.6394767917544117 | 0.5950335462116101 |
| 0.3412531833281345 | 0.8104054910573486 |
| 0.6726172734860898 | 0.3750576176542233 |
| 0.6113010593290971 | 0.6031731297612366 |
| 0.0870844331431877 | 0.7003199617863123 |
10 items
import pandas as pdimport numpy as npx = pd.DataFrame({"x": np.random.rand(10), "asjdkasdj": np.random.rand(10)})x0.8s
Python
| x | asjdkasdj | |
|---|---|---|
| 0 | 0.5198053379615182 | 0.8145266334454069 |
| 1 | 0.4010959161417218 | 0.5026947276751768 |
| 2 | 0.3462879933281545 | 0.22826987334201154 |
| 3 | 0.48981068824264284 | 0.3300664188943968 |
| 4 | 0.0016739957729958732 | 0.816789730229122 |
| 5 | 0.5518653243085081 | 0.598266509057624 |
| 6 | 0.9303599906271144 | 0.7946055995174718 |
| 7 | 0.47990631712483167 | 0.9471247490222806 |
| 8 | 0.20782254299522585 | 0.03409555654878671 |
| 9 | 0.6579067635099278 | 0.14749341535234872 |
10 items
x = runif(10)asjdkasdj = runif(10)data.frame(x, asjdkasdj)0.2s
echo "\"x\",\"asjdkasdj\"0.886204954236746,0.9947493541985750.939964033663273,0.3483422070275990.841421562014148,0.2515358813107010.191597430035472,0.1695398036390540.552916625980288,0.9571689052972940.649154531303793,0.3362265920732170.834337387699634,0.2928915873635560.940559577196836,0.01465194276534020.062867890112102,0.1927295255009080.500695133814588,0.318394189001992" > /results/test.csv0.4s
Bash in Clojure
0 items
HTML
HTML("<h3>hi</h3>")0.6s
Julia
hi
class HTML(object): def _repr_html_(self): return '<h3>hi</h3>' HTML()0.2s
Python
hi
{:nextjournal/viewer "html" :nextjournal.viewer/value "<h3>hi</h3>"}0.1s
Clojure
hi
echo '<h3>hi</h3>' > /results/test.html0.4s
Bash in Clojure
IFrame
using WebSockets, WebIO, Interacts = for i in 1:10 "hello number: $i"endWebIO.node(:div, s, style = Dict(:height => 80))0.9s
library(leaflet)options(nextjournal.display.htmlwidgetsEnabled=TRUE)leaflet() %>% addTiles() %>% # Add default OpenStreetMap map tiles addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")1.9s
PNG

struct PNG endfunction Base.show(io::IO, ::MIME"image/png", ::PNG) write(io, read(test.png))endPNG()1.6s
Julia
class PNG(object): def _repr_png_(self): f = open(test.png, "rb") bin = f.read() f.close() return bin PNG()0.2s
Python
cp NJ__REF_ /results/test.png0.2s
Bash in Python
JPEG

struct JPEG endfunction Base.show(io::IO, ::MIME"image/jpeg", ::JPEG) write(io, read(test_image.jpg))endJPEG()0.8s
Julia
class JPEG(object): def _repr_jpeg_(self): f = open(test_image.jpg, "rb") bin = f.read() f.close() return bin JPEG()0.2s
Python
cp NJ__REF_ /results/test.jpg0.2s
Bash in Python
SVG
struct SVG endfunction Base.show(io::IO, ::MIME"image/svg+xml", ::SVG) write(io, read(test.svg))endSVG()2.4s
Julia
class SVG(object): def _repr_svg_(self): f = open(test.svg, "r") bin = f.read() f.close() return bin SVG()0.2s
Python
cp NJ__REF_ /results/test.svg0.2s
Bash in Python
Plotly
using PlotlyBasePlotlyBase.Plot(1:10, (1:10) .^ 2)4.6s
Julia
import plotly.graph_objs as goimport numpy as npx = np.arange(10)fig = go.Figure(data=[go.Scatter(x=x, y=x**2)])fig1.2s
Python
{:nextjournal/viewer :plotly}{:data [{ :x [1 2 3 4 5 6 7 8 9 10] :y [1 4 9 16 25 36 49 64 81 100]}]}0.1s
Clojure
Vegalite
{:nextjournal/viewer "vega-lite"}{:width 650 :height 400 :data {:url "https://vega.github.io/vega-datasets/data/us-10m.json" :format {:type "topojson" :feature "counties"}} :transform [{:lookup "id" :from {:data {:url "https://vega.github.io/vega-datasets/data/unemployment.tsv"} :key "id" :fields ["rate"]}}] :projection {:type "albersUsa"} :mark "geoshape" :encoding {:color {:field "rate" :type "quantitative"}}}0.2s
Clojure
echo '{ "width": 500, "height": 300, "data": {"url": "https://vega.github.io/vega-datasets/data/unemployment-across-industries.json"}, "mark": "area", "encoding": { "x": { "timeUnit": "yearmonth", "field": "date", "type": "temporal", "axis": {"domain": false, "format": "%Y", "tickSize": 0} }, "y": { "aggregate": "sum", "field": "count","type": "quantitative", "axis": null, "stack": "center" }, "color": { "field":"series", "type":"nominal", "scale":{"scheme": "category20b"} } }}' > /results/plot.vl.json0.3s
Bash in Clojure
Loading viewer…
pip install altair5.1s
Bash in Python
import altair as altsource = "https://vega.github.io/vega-datasets/data/unemployment-across-industries.json"alt.Chart(source).mark_area().encode( alt.X('yearmonth(date):T', axis=alt.Axis(format='%Y', domain=False, tickSize=0) ), alt.Y('sum(count):Q', stack='center', axis=None), alt.Color('series:N', scale=alt.Scale(scheme='category20b') )).interactive()1.2s
Python
Latex
struct Latex endfunction Base.show(io::IO, ::MIME"text/latex", ::Latex) print(io, "\\int_0^\\infty e^{-x^2} dx=\\frac{\\sqrt{\\pi}}{2}")endLatex()0.5s
Julia
class Latex(object): def _repr_latex_(self): return "\\int_0^\\infty e^{-x^2} dx=\\frac{\\sqrt{\\pi}}{2}" Latex()0.3s
Python
echo "\\int_0^\\infty e^{-x^2} dx=\\frac{\\sqrt{\\pi}}{2}" > "/results/test.latex"0.1s
Bash in Python
{:nextjournal/viewer "formula" :nextjournal.viewer/value "\\int_0^\\infty e^{-x^2} dx=\\frac{\\sqrt{\\pi}}{2}"}0.1s
Clojure
Plain
1:100.5s
Julia
1:10
()-> "this is a function"0.7s
Julia
#5 (generic function with 1 method)
class Plain: def test(): return ""Plain()0.2s
Python
<Plain object...x7ff417accf60>
def func(msg): print(msg)func0.2s
Python
<function fun...x7ff4202aaae8>
{:nextjournal/viewer "text" :nextjournal.viewer/value "hi"}0.0s
Clojure
hi
echo "hi" > /results/test.txt0.2s
Bash in Clojure
empty
list(1, 2, 3)0.5s
f <- function(x){x + 1}f0.4s
JSON
struct APP_JSON endfunction Base.show(io::IO, ::MIME"application/json", ::APP_JSON) JSON.print(io, Dict(:data => [2,3,4]))endAPP_JSON()0.7s
Julia
Object {data: Array(3)}
class JSON(object): def _repr_json_(self): return "{\"data\":[2,3,4]}" JSON()0.2s
Python
Object {data: Array(3)}
echo "{\"data\":[2,3,4]}" > /results/test.json0.2s
Bash in Clojure
nil
{:data [2 3 4]}0.0s
Clojure
Map {:data: Vector(3)}