Skip to content

Commit

Permalink
Merge pull request #143 from K3D-tools/devel
Browse files Browse the repository at this point in the history
Devel -> Master
  • Loading branch information
artur-trzesiok authored Apr 30, 2019
2 parents 222d118 + 12b5f5d commit 5c6a599
Show file tree
Hide file tree
Showing 60 changed files with 1,855 additions and 2,736 deletions.
40 changes: 4 additions & 36 deletions examples/01_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e35d2aeabc7c4903810d081d090f040b",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Output</code>.</p>\n",
"<p>\n",
" If you're reading this message in Jupyter Notebook or JupyterLab, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another notebook frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import k3d\n",
"plot = k3d.plot()\n",
Expand All @@ -74,9 +44,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -97,7 +65,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 2 additions & 4 deletions examples/02_adding_objects_to_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -145,7 +143,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 2 additions & 4 deletions examples/03_plotting_a_single_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -65,7 +63,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
15 changes: 6 additions & 9 deletions examples/04_gui_basics.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/05_plot_options.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.5"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
26 changes: 16 additions & 10 deletions examples/Menger_sponge_clipping_planes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@
"metadata": {},
"outputs": [],
"source": [
"plot.camera = [\n",
"0.4566373872959987,\n",
"-1.1828440889740142,\n",
"0.8152559691722203,\n",
"0.12721661836556944,\n",
"0.010204975470810503,\n",
"-0.1292622376887978,\n",
"-0.19179675209811095,\n",
"0.5291470859180342,\n",
"0.8265696385357213]"
"plot.camera = [49.74392405695982,\n",
" -2.9524769249925455,\n",
" 27.185488598217045,\n",
" 43.65220601477353,\n",
" 19.109636932275787,\n",
" 9.719259554462269,\n",
" -0.19179675209811095,\n",
" 0.5291470859180342,\n",
" 0.8265696385357213]"
]
},
{
Expand Down Expand Up @@ -89,6 +88,13 @@
"source": [
"plot.clipping_planes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2"
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
55 changes: 23 additions & 32 deletions examples/Sine_Gordon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"N = 153\n",
Expand All @@ -55,15 +53,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"y0 = np.zeros(2*N)\n",
"x = y0[:N] # Fist N variables are positions\n",
"v = y0[N:]\n",
"ksi = np.linspace(-5,25,N)\n",
"ksi = np.linspace(-5,25,N, dtype=np.float32)\n",
"h = np.diff(ksi)[0]\n",
"\n",
"instanton = lambda x,v,t: 4 * np.arctan(np.exp( (x-v*t)/np.sqrt(1-v**2) ))\n",
Expand All @@ -72,17 +68,13 @@
"v[:] = -v1/h*np.gradient( instanton(ksi,v1,0) )\n",
"\n",
"x[:] += instanton(ksi,v2,50)\n",
"v[:] += -v2/h*np.gradient( instanton(ksi,v2,50) )\n",
"\n",
"\n"
"v[:] += -v2/h*np.gradient( instanton(ksi,v2,50) )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"def lhs(y_,t):\n",
Expand All @@ -95,35 +87,30 @@
" y[N-1] = 0 \n",
" return y\n",
"ts = np.linspace(0,140,50) \n",
"%time xt = odeint(lhs,y0, ts)"
"%time xt = odeint(lhs,y0, ts).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"import k3d\n",
"import numpy as np\n",
"import time \n",
"plot = k3d.plot()\n",
"r = .6\n",
"origins = np.vstack([ksi,np.zeros(N),np.zeros(N)] ).T.copy()\n",
"vectors = np.vstack([np.zeros(N),r*np.sin(xt[0,:N]),r*np.cos(xt[0,:N])] ).T\n",
"origins = np.vstack([ksi,np.zeros(N),np.zeros(N)]).T.copy().astype(np.float32)\n",
"vectors = np.vstack([np.zeros(N),r*np.sin(xt[0,:N]),r*np.cos(xt[0,:N])] ).T.astype(np.float32)\n",
"\n",
"vector_plot = k3d.vectors(origins, vectors)\n",
"line_plot = k3d.line(vectors+origins,color=0xff0000)\n",
"line_plot = k3d.line(vectors + origins,color=0xff0000)\n",
"\n",
"plot += vector_plot\n",
"plot += line_plot\n",
"plot.display()\n",
"\n",
"plot.camera_auto_fit = False\n",
"plot.grid_auto_fit = False\n",
"\n",
"def update_plot(xx):\n",
" vectors = np.vstack([np.zeros_like(xx),r*np.sin(xx),r*np.cos(xx)] ).T\n",
" vector_plot.vectors = vectors.copy()\n",
Expand All @@ -133,9 +120,17 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"plot.camera_auto_fit = False\n",
"plot.grid_auto_fit = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time \n",
Expand All @@ -148,9 +143,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import widgets,interact\n",
Expand All @@ -163,9 +156,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand Down
14 changes: 4 additions & 10 deletions examples/camera_manipulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"z = np.linspace(zmin,zmax,Nz)\n",
"x,y,z = np.meshgrid(x,y,z,indexing='ij')\n",
"p = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))\n",
"iso = k3d.marching_cubes(p,xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)\n",
"iso = k3d.marching_cubes(p.astype(np.float32),xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)\n",
"plot += iso\n",
"\n",
"plot.display()"
Expand All @@ -57,9 +57,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"# camera [posx,posy,posz,targetx,targety,targetz,upx,upy,upz]"
Expand All @@ -68,9 +66,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"# this will reset camera angle after changing `x`\n",
Expand All @@ -80,9 +76,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
Expand Down
4 changes: 2 additions & 2 deletions examples/iris_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"end_time": "2019-04-18T20:40:51.830949Z",
"start_time": "2019-04-18T20:40:51.775439Z"
},
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -265,7 +265,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
Loading

1 comment on commit 5c6a599

@artur-trzesiok
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.