- Create a script that looks like this...
get_ipython().run_line_magic('matplotlib', 'inline')
import random
import math
import matplotlib.pyplot as plt
import numpy as np
import pymc3 as pm
def roll_die():
return random.randint(1, 6)
def roll_dice():
return roll_die() + roll_die()
print(roll_dice())
print(roll_dice())
print(roll_dice())
#%%
def roll_histogram(samples):
rolls = []
for _ in range(samples):
rolls.append(roll_dice())
fig, ax = plt.subplots(figsize=(12, 9))
plt.hist(rolls, bins=11)
roll_histogram(100000)
- Debug through the first cell --- Press "Debug cell" and then F10 through it. Notice that when you hit a "def" line the debugger steps over it because it's a function after all. Find yourself squealing in enjoyment as you step over each individual print(roll_dice()) and see the output as it happens.
- Do the same for the next cell. Step over "def roll_histogram" then F10 on the call to it.
- Bug1 (Not the topic of THIS bug) - the F10 doesn't return successfully and complains about not finding a source file.
- Stop debugging.
- Scratch your chin and decide that you want to step into the debug the roll_histogram() function.
- Set a breakpoint on the first line.
- Press Debug cell again.
Get freaked out that it seems like the debugger is accidentally stopping at a breakpoint in roll_histogram() BEFORE it's called. Then realize that is not happened. What's happening is that since you entered a breakpoint in the cell, the Debug cell function runs to it.
I don't think this is a good idea anymore.
get_ipython().run_line_magic('matplotlib', 'inline')
import random
import math
import matplotlib.pyplot as plt
import numpy as np
import pymc3 as pm
def roll_die():
return random.randint(1, 6)
def roll_dice():
return roll_die() + roll_die()
print(roll_dice())
print(roll_dice())
print(roll_dice())
#%%
def roll_histogram(samples):
rolls = []
for _ in range(samples):
rolls.append(roll_dice())
roll_histogram(100000)
Get freaked out that it seems like the debugger is accidentally stopping at a breakpoint in roll_histogram() BEFORE it's called. Then realize that is not happened. What's happening is that since you entered a breakpoint in the cell, the Debug cell function runs to it.
I don't think this is a good idea anymore.