Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfekete committed Jun 29, 2021
1 parent 5498083 commit a814023
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 25 deletions.
42 changes: 27 additions & 15 deletions notebooks/VegaHeatmap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "downtown-toronto",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0620ef3a615c47b89511634a5bab0624",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(VegaWidget(), IntProgress(value=0, description='progress')))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import time\n",
Expand Down Expand Up @@ -69,19 +84,19 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"id": "393a3fc4",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "182aa12213614b5fab22f22b14652f4b",
"model_id": "2c3a03a90b554107bb871868609e1e02",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(VegaWidget(), IntProgress(value=0, description='progress'), FloatText(value=0.0, description='T"
"VBox(children=(VegaWidget(), IntProgress(value=0, description='progress'), Text(value='', description='Mean ti"
]
},
"metadata": {},
Expand Down Expand Up @@ -119,8 +134,8 @@
"widget.compression = LZ4Compressor(2)\n",
"steps = 100\n",
"progress = widgets.IntProgress(value=0, min=0, max=steps, description='progress', orientation='horizontal')\n",
"mean = widgets.FloatText(value=0, description='Time mean', disables=True)\n",
"std = widgets.FloatText(value=0, description='Time std ', disables=True)\n",
"mean = widgets.Text(value=\"\", description='Mean time', disables=True)\n",
"std = widgets.Text(value=\"\", description='Std time ', disables=True)\n",
"display(widgets.VBox([widget, progress, mean, std]))\n",
"nsamples=100_000\n",
"means = [0.1, 0.3]\n",
Expand All @@ -130,7 +145,6 @@
" hist = np.zeros((nbins,nbins), dtype='uint32')\n",
" step = 0\n",
" times = []\n",
" last = 0\n",
" for sl in np.split(rdata, steps):\n",
" progress.value = step\n",
" step += 1\n",
Expand All @@ -143,14 +157,12 @@
" # value = hist/max\n",
" value = hist\n",
" widget._displayed = True\n",
" start = time.time()\n",
" widget.update_array2d('data', value, ['x', 'y', 'z'], remove=\"true\")\n",
" now = time.time()\n",
" if last:\n",
" times.append(now - last)\n",
" mean.value = np.mean(times)\n",
" std.value = np.std(times)\n",
" last = now\n",
"\n",
" times.append(time.time() - start)\n",
" mean.value = f\"{np.mean(times)*1000:.3f}ms\"\n",
" std.value = f\"{np.std(times)*1000:.3f}ms\"\n",
" \n",
"await progressive_loop(widget, nbins)"
]
},
Expand Down
18 changes: 9 additions & 9 deletions notebooks/VegaLarge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "7205eebf",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "19b9d36d1a3f4a27bd001135b0b99d0f",
"model_id": "5bfa33f65a974a008e5e06b50c61d6ee",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -165,8 +165,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 182 ms, sys: 0 ns, total: 182 ms\n",
"Wall time: 182 ms\n"
"CPU times: user 191 ms, sys: 6.33 ms, total: 198 ms\n",
"Wall time: 197 ms\n"
]
}
],
Expand All @@ -178,14 +178,14 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "01cf9438",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d433d35f26584a48b9c5509a8c95ae3b",
"model_id": "bc850e75492c410ba57b91a434cd60fc",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -200,15 +200,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 41.9 ms, sys: 8.6 ms, total: 50.5 ms\n",
"Wall time: 50.1 ms\n"
"CPU times: user 27.8 ms, sys: 11.6 ms, total: 39.4 ms\n",
"Wall time: 38.4 ms\n"
]
}
],
"source": [
"from vega.dataframes.compressors import LZ4Compressor\n",
"widget = VegaWidget(spec=spec_no_data)\n",
"widget.compression = LZ4Compressor(2)\n",
"widget.compression = \"lz4\"\n",
"display(widget)\n",
"%time widget.update_dataframe('data', df)"
]
Expand Down
1 change: 0 additions & 1 deletion vega/dataframes/progressivis_adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy as np
from .source_adapter import SourceAdapter


Expand Down

0 comments on commit a814023

Please sign in to comment.