Skip to content

Instantly share code, notes, and snippets.

@altavir
Created June 29, 2021 13:39
Show Gist options
  • Save altavir/dd3490148f4962d473a1b9f8bdc2f366 to your computer and use it in GitHub Desktop.
Save altavir/dd3490148f4962d473a1b9f8bdc2f366 to your computer and use it in GitHub Desktop.
Casus sccience seminar materials
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "56b39752-45f7-4095-aa64-fd2e25161b7b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%use plotly-server\n",
"%use dataframe"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "20ae4dc8-ba18-489a-8797-3e7c0f3d4aa5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"var trace: Trace? = null\n",
"\n",
"Plotly.plot { \n",
" trace = scatter{\n",
" x.numbers = (0..100).map{it.toDouble() / 25}\n",
" y.numbers = x.numbers.map{sin(it.toDouble())}\n",
" }\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5abe73e0-5b1e-4b27-aca7-87f7667839a4",
"metadata": {},
"outputs": [],
"source": [
"import kotlinx.coroutines.*\n",
"\n",
"val job = GlobalScope.launch{\n",
" var t = 0\n",
" while(isActive){\n",
" delay(100)\n",
" t+=50\n",
" with(trace){\n",
" y.numbers = x.numbers.map{sin(it.toDouble() +t.toDouble()/2000)}\n",
" }\n",
" }\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "afa4bf5b-c5c6-4840-b5b3-9a71868e3e9d",
"metadata": {},
"outputs": [],
"source": [
"job.cancel()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c1ca5218-3d32-4022-abf1-25b474ef92cf",
"metadata": {},
"outputs": [],
"source": [
"val df = DataFrame.read(\"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42c24135-23b4-4ed1-8e40-83e88bce3c23",
"metadata": {},
"outputs": [],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "07dd08b5-8f1a-4685-88df-23371939af80",
"metadata": {},
"outputs": [],
"source": [
"val df1 = df.add(\"custom\"){sepal_width + petal_length}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bd3e48cb-8964-4bd1-ab0b-976c79f0a54b",
"metadata": {},
"outputs": [],
"source": [
"df1.custom"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "808b034e-c7ab-4bfd-a748-6143d5e5b81b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.5.30-dev-598"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
@altavir
Copy link
Author

altavir commented Jun 29, 2021

The cell content was cleared to limit notebook size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment