literate computing - interactive literate programming¤
literate computing relies on a rapid feedback from the computer.
pidgy
features multiple reactive/interactive displays for presenting your content.
we'll explore the displays and meaning with two demos:
1. the cookies demo
2. the dataframe demo
cookies demo¤
the cookies demo is mainstay in the deathbeds repertoire.
inspired by bret viktors tanglejs we explore the cookie demo in pidgy
.
%reload_ext pidgy
import pidgy
shell.displays_manager.template_cls = pidgy.weave.IPyWidgetsHtml
cookies = IntSlider(3)
<style>
#hunger {
opacity: {{cookies.value/20}};
font-size: {{cookies.value/20}}rem;
background-image: url("https://media4.giphy.com/media/BsUORZkF3gBqg/giphy.gif");
background-size: cover;
}
</style>
<div id="hunger">cookies!
cookies!
cookies!
</div>
if i eat {{cookies.value}} then i consume {{cookies.value*50}} calories.
shell.displays_manager.template_cls = pidgy.weave.IPyWidgetsHtml
if i eat {{cookies.value}} then i consume {{cookies.value*50}} calories.
shell.displays_manager.template_cls = pidgy.weave.IPythonHtml
if i eat {{cookies.value}} then i consume {{cookies.value*50}} calories.
shell.displays_manager.template_cls = pidgy.weave.IPythonMarkdown
if i eat 3 then i consume 150 calories.
shell.displays_manager.template_cls = pidgy.weave.IPythonMarkdown
cookies
cookies
Dataframes¤
from ipywidgets import interact_manual
from ipywidgets import interact_manual
import pandas
who = Text("tonyfast")
import pandas
who = Text("tonyfast")
shell.displays_manager.template_cls = pidgy.weave.IPyWidgetsHtml
{{g.T}}
shell.displays_manager.template_cls = pidgy.weave.IPythonHtml
{{g.T}}
shell.displays_manager.template_cls = pidgy.weave.IPythonMarkdown
{{g.T}}
shell.displays_manager.template_cls = pidgy.weave.IPythonMarkdown
g is undefined
g = df.iloc[:5, :5]
def update(who):
global df, g
g = df = pandas.read_json(F"https://api.github.com/users/{who}/gists")
interact_manual(update, who=who)
def update(who):
global df, g
g = df = pandas.read_json(F"https://api.github.com/users/{who}/gists")
interact_manual(update, who=who)