diff --git a/README.md b/README.md index 432ad468..babab7ab 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ repositories { } dependencies { - implementation("com.github.breandan:kotlingrad:0.4.1") + implementation("com.github.breandan:kotlingrad:0.4.2") } ``` @@ -99,7 +99,7 @@ dependencies { com.github.breandan kotlingrad - 0.4.1 + 0.4.2 ``` @@ -109,7 +109,8 @@ dependencies { To access Kotlin∇'s notebook support, use the following line magic: ``` -%use @https://raw.githubusercontent.com/breandan/kotlingrad/master/core/kotlingrad.json +@file:Repository("https://jitpack.io") +@file:DependsOn("com.github.breandan:kotlingrad:0.4.2") ``` For more information, explore the [tutorial](samples/notebooks/hello_kotlingrad.ipynb). diff --git a/build.gradle.kts b/build.gradle.kts index 92bb51a0..93b7c3a5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ allprojects { } group = "com.github.breandan" - version = "0.4.1" + version = "0.4.2" apply(plugin = "org.jetbrains.kotlin.jvm") diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8f67b551..9aae8b43 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -4,7 +4,7 @@ plugins { `maven-publish` id("shipshape") idea - kotlin("jupyter.api") version "0.8.3.255" + kotlin("jupyter.api") version "0.8.3.268" } // TODO: Maybe move this into the plugin somehow? diff --git a/core/kotlingrad.json b/core/kotlingrad.json deleted file mode 100644 index 6f099bdf..00000000 --- a/core/kotlingrad.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "link": "https://github.com/breandan/kotlingrad", - "description": "A shape-safe symbolic differentiation framework for Kotlin", - "dependencies": [ - "com.github.breandan:kotlingrad:0.4.1", - "com.github.breandan:kaliningraph:0.1.5" - ], - "imports": [ - "edu.umontreal.kotlingrad.api.*", - "edu.mcgill.kaliningraph.*" - ], - "renderers": { - "edu.umontreal.kotlingrad.api.Sine" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Cosine" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Tangent" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Negative" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Sum" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Prod" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Power" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Log" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Derivative" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.SComposition" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.DProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VSumAll" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.SVar" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.SConst" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.SFun" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VNegative" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VMap" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VSum" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VVProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.SVProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VSProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.MVProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VMProd" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.MSumRows" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VDerivative" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Gradient" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VVar" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VComposition" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.Vec" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.VFun" : "HTML($it.html())", - "edu.umontreal.kotlingrad.api.MFun" : "HTML($it.html())" - } -} diff --git a/core/src/main/kotlin/edu/umontreal/kotlingrad/api/KotlinJupyter.kt b/core/src/main/kotlin/edu/umontreal/kotlingrad/api/KotlinJupyter.kt index 2bace4c7..c311f1f8 100644 --- a/core/src/main/kotlin/edu/umontreal/kotlingrad/api/KotlinJupyter.kt +++ b/core/src/main/kotlin/edu/umontreal/kotlingrad/api/KotlinJupyter.kt @@ -1,21 +1,20 @@ package edu.umontreal.kotlingrad.api -//import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary -//import org.jetbrains.kotlinx.jupyter.api.* -//import org.jetbrains.kotlinx.jupyter.api.libraries.* -// -//@JupyterLibrary -//class Integration: JupyterIntegration() { -// override fun Builder.onLoaded() { -// listOf( -// "edu.umontreal.kotlingrad.api.*", -//// "edu.mcgill.kaliningraph.*" -// ).forEach { import(it) } -// -//// render> { HTML(it.render().toString()) } -// -// // https://github.com/Kotlin/kotlin-jupyter/blob/master/docs/libraries.md#integration-using-kotlin-api -// // https://github.com/nikitinas/dataframe/blob/master/src/main/kotlin/org/jetbrains/dataframe/jupyter/Integration.kt -// // https://github.com/mipt-npm/visionforge/blob/dev/demo/jupyter-playground/src/main/kotlin/hep/dataforge/playground/VisionForgePlayGroundForJupyter.kt -// } -//} \ No newline at end of file +import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary +import org.jetbrains.kotlinx.jupyter.api.* +import org.jetbrains.kotlinx.jupyter.api.libraries.* + +@JupyterLibrary +class Integration: JupyterIntegration() { + override fun Builder.onLoaded() { + listOf( + "edu.umontreal.kotlingrad.api.*", + ).forEach { import(it) } + + render> { HTML(it.render().toString()) } + + // https://github.com/Kotlin/kotlin-jupyter/blob/master/docs/libraries.md#integration-using-kotlin-api + // https://github.com/nikitinas/dataframe/blob/master/src/main/kotlin/org/jetbrains/dataframe/jupyter/Integration.kt + // https://github.com/mipt-npm/visionforge/blob/dev/demo/jupyter-playground/src/main/kotlin/hep/dataforge/playground/VisionForgePlayGroundForJupyter.kt + } +} \ No newline at end of file diff --git a/kaliningraph b/kaliningraph index 8195ae5b..5982c293 160000 --- a/kaliningraph +++ b/kaliningraph @@ -1 +1 @@ -Subproject commit 8195ae5bb1059ba6ab367fac964771330986bf15 +Subproject commit 5982c293c796cc76ac33014adb0d75f11f979d26 diff --git a/samples/notebooks/hello_kotlingrad.ipynb b/samples/notebooks/hello_kotlingrad.ipynb index 3715a46b..57c2d189 100644 --- a/samples/notebooks/hello_kotlingrad.ipynb +++ b/samples/notebooks/hello_kotlingrad.ipynb @@ -2,16 +2,17 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ - "%use @https://raw.githubusercontent.com/breandan/kotlingrad/master/core/kotlingrad.json" + "@file:Repository(\"*mavenLocal\")\n", + "@file:DependsOn(\"com.github.breandan:kotlingrad:0.4.2\")" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -22,412 +23,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.\n", - "INFO node '52d13' -> 'color' has its default value 'black'.\n", - "INFO node '52d13' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '33a6d' -> 'color' has its default value 'black'.\n", - "INFO node '33a6d' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '87f69' -> 'color' has its default value 'black'.\n", - "INFO node '87f69' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '0257c' -> 'color' has its default value 'black'.\n", - "INFO node '0257c' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '-2.0' -> 'color' has its default value 'black'.\n", - "INFO node '-2.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '1c92b' -> 'color' has its default value 'black'.\n", - "INFO node '1c92b' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'x' -> 'color' has its default value 'black'.\n", - "INFO node 'x' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '450b7' -> 'color' has its default value 'black'.\n", - "INFO node '450b7' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'e1356' -> 'color' has its default value 'black'.\n", - "INFO node 'e1356' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'f2e72' -> 'color' has its default value 'black'.\n", - "INFO node 'f2e72' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '44010' -> 'color' has its default value 'black'.\n", - "INFO node '44010' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '07bef' -> 'color' has its default value 'black'.\n", - "INFO node '07bef' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '63be6' -> 'color' has its default value 'black'.\n", - "INFO node '63be6' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '3.0' -> 'color' has its default value 'black'.\n", - "INFO node '3.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'y' -> 'color' has its default value 'black'.\n", - "INFO node 'y' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '66b9d' -> 'color' has its default value 'black'.\n", - "INFO node '66b9d' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '3ee56' -> 'color' has its default value 'black'.\n", - "INFO node '3ee56' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'eeecc' -> 'color' has its default value 'black'.\n", - "INFO node 'eeecc' -> 'fontcolor' has its default value 'black'.\n", - "INFO node 'z' -> 'color' has its default value 'black'.\n", - "INFO node 'z' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '-1.0' -> 'color' has its default value 'black'.\n", - "INFO node '-1.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '-3.0' -> 'color' has its default value 'black'.\n", - "INFO node '-3.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '1.0' -> 'color' has its default value 'black'.\n", - "INFO node '1.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO node '2.0' -> 'color' has its default value 'black'.\n", - "INFO node '2.0' -> 'fontcolor' has its default value 'black'.\n", - "INFO link '52d13--33a6d' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '33a6d--87f69' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '0257c--33a6d' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '-2.0--87f69' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '1c92b--52d13' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'x--52d13' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'x--450b7' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '450b7--e1356' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'e1356--f2e72' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'f2e72--44010' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '44010--07bef' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '07bef--1c92b' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '63be6--0257c' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '3.0--0257c' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'y--1c92b' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'y--66b9d' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'y--44010' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'y--3ee56' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '66b9d--63be6' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '3ee56--eeecc' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'eeecc--07bef' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'z--63be6' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link 'z--eeecc' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '-1.0--66b9d' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '-1.0--3ee56' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '-3.0--f2e72' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '1.0--e1356' -> 'arrowhead' has its default value 'normal'.\n", - "INFO link '2.0--450b7' -> 'arrowhead' has its default value 'normal'.\n", - "input file:///tmp/GraphvizJava/DotEngine1998790069004436690/dotfile.dot\n", - "executing command [/bin/sh, -c, dot -Kdot -Tsvg /tmp/GraphvizJava/DotEngine1998790069004436690/dotfile.dot -ooutfile.svg]\n", - "output file:///tmp/GraphvizJava/DotEngine1998790069004436690/outfile.svg\n" - ] - }, { "data": { - "text/html": [ - "\n", - "\n", - "%3\n", - "\n", - "\n", - "52d13\n", - "\n", - "d\n", - "\n", - "\n", - "\n", - "33a6d\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "52d13->33a6d\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "87f69\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "33a6d->87f69\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "0257c\n", - "\n", - "*\n", - "\n", - "\n", - "\n", - "0257c->33a6d\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "-2.0\n", - "\n", - "-2.0\n", - "\n", - "\n", - "\n", - "-2.0->87f69\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "1c92b\n", - "\n", - "d\n", - "\n", - "\n", - "\n", - "1c92b->52d13\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "x\n", - "\n", - "x\n", - "\n", - "\n", - "\n", - "x->52d13\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "450b7\n", - "\n", - "*\n", - "\n", - "\n", - "\n", - "x->450b7\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "e1356\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "450b7->e1356\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "f2e72\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "e1356->f2e72\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "44010\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "f2e72->44010\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "07bef\n", - "\n", - "+\n", - "\n", - "\n", - "\n", - "44010->07bef\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "07bef->1c92b\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "63be6\n", - "\n", - "*\n", - "\n", - "\n", - "\n", - "63be6->0257c\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "3.0\n", - "\n", - "3.0\n", - "\n", - "\n", - "\n", - "3.0->0257c\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "y\n", - "\n", - "y\n", - "\n", - "\n", - "\n", - "y->1c92b\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "y->44010\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "66b9d\n", - "\n", - "pow\n", - "\n", - "\n", - "\n", - "y->66b9d\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "3ee56\n", - "\n", - "pow\n", - "\n", - "\n", - "\n", - "y->3ee56\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "66b9d->63be6\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "eeecc\n", - "\n", - "*\n", - "\n", - "\n", - "\n", - "3ee56->eeecc\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "eeecc->07bef\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "z\n", - "\n", - "z\n", - "\n", - "\n", - "\n", - "z->63be6\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "z->eeecc\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "-1.0\n", - "\n", - "-1.0\n", - "\n", - "\n", - "\n", - "-1.0->66b9d\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "-1.0->3ee56\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "-3.0\n", - "\n", - "-3.0\n", - "\n", - "\n", - "\n", - "-3.0->f2e72\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "1.0\n", - "\n", - "1.0\n", - "\n", - "\n", - "\n", - "1.0->e1356\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "2.0\n", - "\n", - "2.0\n", - "\n", - "\n", - "\n", - "2.0->450b7\n", - "\n", - "\n", - "\n", - "\n", - "\n" + "text/plain": [ + "((d(d(((((1.0) + ((x) * (2.0))) + (-3.0)) + (y)) + ((z) * ((y) pow (-1.0)))) / d(y)) / d(x)) + (((z) * ((y) pow (-1.0))) * (3.0))) + (-2.0)" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -455,8 +60,9 @@ "file_extension": ".kt", "mimetype": "text/x-kotlin", "name": "kotlin", + "nbconvert_exporter": "", "pygments_lexer": "kotlin", - "version": "1.4.20-dev-3647" + "version": "1.4.30" } }, "nbformat": 4,