Skip to content

Commit

Permalink
fix #7539 by adding clojure examples (#7552)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdraves authored Jun 20, 2018
1 parent 4757230 commit 670a761
Showing 1 changed file with 102 additions and 2 deletions.
104 changes: 102 additions & 2 deletions doc/clojure/Clojure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@
"(. classpathTest getObjectTest)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Array of Maps with Properties"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -142,6 +149,13 @@
"[{:foo 1}{:foo 2}]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive Plot"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -159,6 +173,38 @@
" (.setY [0, 1, 6, 5, 2, 8]))))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## EasyForm"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(def form (doto (com.twosigma.beakerx.easyform.EasyForm. \"Test Form\")\n",
" (.addTextField \"Name\")\n",
" (.addButton \"Reverse\" \"reverse\")))\n",
"form"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"reverse"
]
},
"outputs": [],
"source": [
"(reverse (get form \"Name\"))"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -204,12 +250,53 @@
"(new IntSlider)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## IPyVolume visualization widget\n",
"\n",
"[ipyvolume](https://github.com/maartenbreddels/ipyvolume) works with Clojure, and the other [3D widgets](../groovy/3D.ipynb) probably work too. Note, the widget JS needs to be installed in advance of starting the notebook:\n",
"```\n",
"conda install -c conda-forge ipyvolume\n",
"```\n",
"See the [source of this example](https://github.com/maartenbreddels/ipyvolume/pull/140#issuecomment-394777662)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"%classpath add mvn com.github.twosigma ipyvolume master-SNAPSHOT"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(import ipyvolume.PyLab)\n",
"\n",
"(defn ball \n",
" [size radius]\n",
" (let [data (make-array Float/TYPE size size size)\n",
" square #(* % %)\n",
" center #(- % (/ size 2))\n",
" sum (partial reduce +)\n",
" sum-of-squares #(sum (map square %))]\n",
" (doseq [i (range size)\n",
" j (range size)\n",
" k (range size)\n",
" :let [[x y z] (map center [i j k])] \n",
" :when (> (square radius) \n",
" (sum-of-squares [x y z]))]\n",
" (aset data i j k (float 1)))\n",
" data))\n",
"(PyLab/volShow (ball 32 12))"
]
}
],
"metadata": {
Expand All @@ -225,7 +312,20 @@
"mimetype": "text/x-clojure",
"name": "Clojure",
"nbconverter_exporter": "",
"version": "1.7"
"version": "1.9.0"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down

0 comments on commit 670a761

Please sign in to comment.