Skip to content

Instantly share code, notes, and snippets.

@ccwang002
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccwang002/0f25f2dd4b59312925a1 to your computer and use it in GitHub Desktop.
Save ccwang002/0f25f2dd4b59312925a1 to your computer and use it in GitHub Desktop.
import numpy as np
rs = np.random.RandomState(seed=5566)
n_conditions = 10
# Here we simulate a complex computation, for example, analogy of the magnitude
# of gradient decent which expects to be strictly positive. But from the result
# we find that it seems to be sometimes negative, we wish to find out when and
# what condition our program produces bogus ouput.
#
# This is the case to use pdb and condition break point
result_sum = 0.0
# To enable pdb debug, uncomment the following two lines:
#
# import pdb
# pdb.Pdb(skip=['numpy.*']).set_trace()
#
# setting skip=['some modules'] so we could use 's' (step) into our own code
# instead of debugging every module we use.
for i in range(n_conditions):
complex_out = rs.normal(loc=3.0, scale=0.8, size=1000)
# we found the result is not right sometimes
result_sum += np.sum(complex_out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment