dev cruft

master
ml server 2020-01-22 19:17:54 -07:00
parent 1b8b828877
commit c158e21f3e
1 changed files with 236 additions and 0 deletions

View File

@ -12,6 +12,7 @@
"#\n",
"# GPLv3+\n",
"\n",
"from __future__ import print_function\n",
"import os\n",
"import random\n",
"import tempfile\n",
@ -21,6 +22,241 @@
"from tensorflow.python.keras.models import load_model\n",
"from tensorflow.python.keras.preprocessing.image import ImageDataGenerator\n",
"\n",
"\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Cute SSTV: 1456893\n",
"# December, 2019 range: 1292461 \n",
"obsmin=1292461\n",
"obsmax=1470525\n",
"print(\"Minimum Observation ID: \", obsmin)\n",
"print(\"Maximum Observation ID: \", obsmax)\n",
"\n",
"print(\"Enter a value between the minimum and maximum Observation ID:\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%gui asyncio\n",
"\n",
"import asyncio\n",
"def wait_for_change(widget, value):\n",
" future = asyncio.Future()\n",
" def getvalue(change):\n",
" # make the new value available\n",
" future.set_result(change.new)\n",
" widget.unobserve(getvalue, value)\n",
" widget.observe(getvalue, value)\n",
" return future\n",
"\n",
"from ipywidgets import IntSlider\n",
"slider = IntSlider()\n",
"\n",
"async def f():\n",
" for i in range(10):\n",
" print('did work %s'%i)\n",
" x = await wait_for_change(slider, 'value')\n",
" print('async function continued with value %s'%x)\n",
"asyncio.ensure_future(f())\n",
"\n",
"slider"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obsget = widgets.IntText(value=1456893, disabled=False)\n",
"b = widgets.IntSlider(min=1292461, max=1470525, step=1, value=1456893, continuous_update=True, description='Observation ID:', orientation='vertical', readout=True)\n",
"display(obsget,b)\n",
"mylink = widgets.jslink((obsget, 'value'), (b, 'value'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"print(widgets.Button.on_click.__doc__)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"button = widgets.Button(description=\"Click Me!\")\n",
"output = widgets.Output()\n",
"\n",
"display(button, output)\n",
"\n",
"def on_button_clicked(b):\n",
" with output:\n",
" print(\"Button clicked.\")\n",
"\n",
"button.on_click(on_button_clicked)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = widgets.IntSlider(description=\"Delayed\", continuous_update=False)\n",
"b = widgets.IntText(description=\"Delayed\", continuous_update=False)\n",
"c = widgets.IntSlider(description=\"Continuous\", continuous_update=True)\n",
"d = widgets.IntText(description=\"Continuous\", continuous_update=True)\n",
"\n",
"widgets.link((a, 'value'), (b, 'value'))\n",
"widgets.link((a, 'value'), (c, 'value'))\n",
"widgets.link((a, 'value'), (d, 'value'))\n",
"widgets.VBox([a,b,c,d])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"widgets.IntProgress(\n",
" value=obsget.value,\n",
" min=1292461,\n",
" max=1470525,\n",
" step=1,\n",
" description='Loading:',\n",
" bar_style='success',\n",
" orientation='horizontal'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out = widgets.Output(layout={'border': '5px solid lightblue'})\n",
"#out\n",
"with out:\n",
" for i in range(10):\n",
" print(i, 'Hello world!')\n",
" display(widgets.IntSlider())\n",
"out"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@out.capture()\n",
"#def function_with_captured_output():\n",
" #print('This goes into the output widget')\n",
" #raise Exception('As does this')\n",
"\n",
"#function_with_captured_output()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out.clear_output()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(obsget)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(b.value)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(obsget.value)\n",
"obsget.continuous_update = True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obsget.keys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(obsget.continuous_update)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(obsget.value)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"barf()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"wut --- What U Think? SatNOGS Observation AI.\")\n",
"print(\"\")\n",
"print(\"wut is an AI that rates SatNOGS Observations good or bad.\")\n",