Playground/README.ipynb

173 lines
51 KiB
Plaintext
Raw Permalink Normal View History

2023-04-09 14:52:22 +02:00
{
"cells": [
2023-04-09 15:22:05 +02:00
{
"cell_type": "markdown",
"source": [
"# Playground\n",
"This is a playground for testing things like the Gitea MD syntax"
],
"metadata": {
"collapsed": false
}
},
2023-04-09 14:52:22 +02:00
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 14,
2023-04-09 14:52:22 +02:00
"metadata": {
"collapsed": true,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:55:57.143918Z",
"end_time": "2023-04-09T16:56:00.513705Z"
2023-04-09 14:52:22 +02:00
}
},
"outputs": [
{
"data": {
2023-04-09 16:57:08 +02:00
"text/html": " <div id=\"jIvOiD\"></div>\n <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n if(!window.letsPlotCallQueue) {\n window.letsPlotCallQueue = [];\n }; \n window.letsPlotCall = function(f) {\n window.letsPlotCallQueue.push(f);\n };\n (function() {\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v3.0.0/js-package/distr/lets-plot.min.js\";\n script.onload = function() {\n window.letsPlotCall = function(f) {f();};\n window.letsPlotCallQueue.forEach(function(f) {f();});\n window.letsPlotCallQueue = [];\n \n \n };\n script.onerror = function(event) {\n window.letsPlotCall = function(f) {};\n window.letsPlotCallQueue = [];\n var div = document.createElement(\"div\");\n div.style.color = 'darkred';\n div.textContent = 'Error loading Lets-Plot JS';\n document.getElementById(\"jIvOiD\").appendChild(div);\n };\n var e = document.getElementById(\"jIvOiD\");\n e.appendChild(script);\n })();\n </script>"
2023-04-09 14:52:22 +02:00
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%use lets-plot"
]
},
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 15,
2023-04-09 14:52:22 +02:00
"outputs": [],
"source": [
"val data = mapOf(\n",
" \"cat1\" to listOf(\"a\", \"a\", \"b\", \"a\", \"a\", \"a\", \"a\", \"b\", \"b\", \"b\", \"b\"),\n",
" \"cat2\" to listOf(\"c\", \"c\", \"d\", \"d\", \"d\", \"c\", \"c\", \"d\", \"c\", \"c\", \"d\")\n",
")\n",
"val p = letsPlot(data)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:56:00.512889Z",
"end_time": "2023-04-09T16:56:00.606630Z"
2023-04-09 14:52:22 +02:00
}
}
},
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 16,
2023-04-09 14:52:22 +02:00
"outputs": [
{
"data": {
2023-04-09 16:57:08 +02:00
"text/html": " <div id=\"SRcLIA\"></div>\n <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n (function() {\n var plotSpec={\n\"mapping\":{\n},\n\"data\":{\n},\n\"kind\":\"plot\",\n\"scales\":[],\n\"layers\":[{\n\"mapping\":{\n\"x\":\"cat1\",\n\"fill\":\"cat2\"\n},\n\"stat\":\"count\",\n\"position\":\"stack\",\n\"geom\":\"bar\",\n\"data\":{\n\"cat2\":[\"c\",\"c\",\"d\",\"d\"],\n\"cat1\":[\"a\",\"b\",\"b\",\"a\"],\n\"..count..\":[4.0,2.0,3.0,2.0]\n}\n}]\n};\n var plotContainer = document.getElementById(\"SRcLIA\");\n window.letsPlotCall(function() {{\n LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n }});\n })(); \n </script>"
2023-04-09 14:52:22 +02:00
},
2023-04-09 16:57:08 +02:00
"execution_count": 16,
2023-04-09 14:52:22 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"val layer = geomBar {\n",
" x = \"cat1\"\n",
" fill = \"cat2\"\n",
"}\n",
"\n",
"(p + layer)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:56:00.606184Z",
"end_time": "2023-04-09T16:56:00.689800Z"
2023-04-09 14:52:22 +02:00
}
}
},
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 17,
2023-04-09 14:52:22 +02:00
"outputs": [],
"source": [
"val rand = java.util.Random(1024)\n",
"val data = mapOf (\n",
" \"rating\" to List(200) { rand.nextGaussian() } + List(200) { rand.nextGaussian() * 1.5 + 1.5 },\n",
" \"cond\" to List(200) { \"A\" } + List(200) { \"B\" }\n",
")\n",
"var p = letsPlot(data)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:56:00.678339Z",
"end_time": "2023-04-09T16:56:00.787205Z"
2023-04-09 14:52:22 +02:00
}
}
},
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 18,
2023-04-09 14:52:22 +02:00
"outputs": [
{
"data": {
2023-04-09 16:57:08 +02:00
"text/html": " <div id=\"pMT6Qu\"></div>\n <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n (function() {\n var plotSpec={\n\"mapping\":{\n},\n\"data\":{\n},\n\"ggsize\":{\n\"width\":700.0,\n\"height\":350.0\n},\n\"kind\":\"plot\",\n\"scales\":[],\n\"layers\":[{\n\"mapping\":{\n\"x\":\"rating\",\n\"fill\":\"cond\"\n},\n\"stat\":\"density\",\n\"color\":\"dark_green\",\n\"alpha\":0.3,\n\"position\":\"identity\",\n\"geom\":\"density\",\n\"data\":{\n\"rating\":[-2.686670101805126,-2.6714155626199645,-2.656161023434803,-2.6409064842496415,-2.62565194506448,-2.6103974058793185,-2.5951428666941574,-2.579888327508996,-2.5646337883238344,-2.549379249138673,-2.5341247099535114,-2.51887017076835,-2.5036156315831883,-2.488361092398027,-2.4731065532128653,-2.4578520140277043,-2.4425974748425427,-2.4273429356573812,-2.4120883964722197,-2.3968338572870582,-2.3815793181018967,-2.366324778916735,-2.3510702397315737,-2.335815700546412,-2.320561161361251,-2.305306622176089,-2.290052082990928,-2.2747975438057666,-2.259543004620605,-2.2442884654354436,-2.229033926250282,-2.2137793870651206,-2.198524847879959,-2.1832703086947975,-2.168015769509636,-2.152761230324475,-2.1375066911393135,-2.122252151954152,-2.1069976127689904,-2.091743073583829,-2.0764885343986674,-2.061233995213506,-2.0459794560283444,-2.030724916843183,-2.015470377658022,-2.00021583847286,-1.9849612992876988,-1.9697067601025373,-1.9544522209173758,-1.9391976817322143,-1.9239431425470528,-1.9086886033618913,-1.8934340641767298,-1.8781795249915685,-1.862924985806407,-1.8476704466212455,-1.8324159074360842,-1.8171613682509227,-1.8019068290657612,-1.7866522898805997,-1.7713977506954381,-1.7561432115102766,-1.7408886723251151,-1.7256341331399538,-1.7103795939547923,-1.6951250547696308,-1.6798705155844693,-1.664615976399308,-1.6493614372141465,-1.634106898028985,-1.6188523588438235,-1.603597819658662,-1.5883432804735007,-1.5730887412883392,-1.5578342021031777,-1.5425796629180162,-1.5273251237328547,-1.5120705845476934,-1.4968160453625319,-1.4815615061773704,-1.4663069669922089,-1.4510524278070474,-1.435797888621886,-1.4205433494367246,-1.405288810251563,-1.3900342710664015,-1.37477973188124,-1.3595251926960787,-1.3442706535109172,-1.3290161143257557,-1.3137615751405942,-1.2985070359554327,-1.2832524967702714,-1.26799795758511,-1.2527434183999484,-1.237488879214787,-1.2222343400296256,-1.206979800844464,-1.1917252616593026,-1.176470722474141,-1.1612161832889796,-1.1459616441038183,-1.1307071049186568,-1.1154525657334953,-1.1001980265483338,-1.0849434873631723,-1.069688948178011,-1.0544344089928495,-1.039179869807688,-1.0239253306225264,-1.008670791437365,-0.9934162522522036,-0.9781617130670421,-0.9629071738818806,-0.9476526346967191,-0.9323980955115576,-0.9171435563263963,-0.9018890171412348,-0.8866344779560733,-0.8713799387709118,-0.8561253995857503,-0.840870860400589,-0.8256163212154275,-0.810361782030266,-0.7951072428451045,-0.779852703659943,-0.7645981644747817,-0.7493436252896202,-0.7340890861044587,-0.7188345469192972,-0.7035800077341356,-0.6883254685489744,-0.6730709293638126,-0.6578163901786516,-0.6425618509934901,-0.6273073118083285,-0.612052772623167,-0.5967982334380055,-0.581543694252844,-0.5662891550676825,-0.551034615882521,-0.5357800766973595,-0.520525537512198,-0.5052709983270369,-0.4900164591418754,-0.4747619199567139,-0.4595073807715524,-0.4442528415863909,-0.4289983024012294,-0.4137437632160679,-0.39848922403090636,-0.38323468484574486,-0.36798014566058335,-0.3527256064754223,-0.3374710672902608,-0.32221652810509926,-0.30696198891993776,-0.29170744973477625,-0.27645291054961474,-0.26119837136445323,-0.24594383217929172,-0.2306892929941302,-0.2154347538089687,-0.20018021462380764,-0.18492567543864613,-0.16967113625348462,-0.1544165970683231,-0.1391620578831616,-0.1239075186980001,-0.10865297951283859,-0.09339844032767708,-0.07814390114251557,-0.06288936195735406,-0.047634822772193,-0.03238028358703149,-0.01712574440186998,-0.0018712052167084714,0.013383333968453037,0.028637873153614546,0.043892412338776055,0.0591469515239
2023-04-09 14:52:22 +02:00
},
2023-04-09 16:57:08 +02:00
"execution_count": 18,
2023-04-09 14:52:22 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p += geomDensity(color=\"dark_green\", alpha=.3) {x=\"rating\"; fill=\"cond\"}\n",
"p + ggsize(700, 350)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:56:00.786558Z",
"end_time": "2023-04-09T16:56:00.886846Z"
2023-04-09 14:52:22 +02:00
}
}
},
{
"cell_type": "code",
2023-04-09 16:57:08 +02:00
"execution_count": 19,
"outputs": [
{
"data": {
"text/plain": "87"
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"12 + 75"
],
2023-04-09 14:52:22 +02:00
"metadata": {
"collapsed": false,
"ExecuteTime": {
2023-04-09 16:57:08 +02:00
"start_time": "2023-04-09T16:56:00.879881Z",
"end_time": "2023-04-09T16:56:00.948068Z"
2023-04-09 14:52:22 +02:00
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"name": "kotlin",
"version": "1.8.0",
"mimetype": "text/x-kotlin",
"file_extension": ".kt",
"pygments_lexer": "kotlin",
"codemirror_mode": "text/x-kotlin",
"nbconvert_exporter": ""
}
},
"nbformat": 4,
"nbformat_minor": 0
}