Skip to content

Instantly share code, notes, and snippets.



Created Nov 15, 2011
What would you like to do?
A simple file with an error for testing interactive debugging
#!/usr/bin/env python
file with deliberate errors to check IPython.
from numpy import *
import time,sys
import sys
#from IPython.Debugger import Tracer; debug_here = Tracer()
g1='a global'
def explode():
a = 'a local variable'
print 'now, we blow up!'
class foo:
"""foo class docstring"""
def __init__(self):
"""init ds"""
class bar:
"""bar class docstring"""
def __init__(self):
"""bar init ds"""
def __call__(self):
"""call ds"""
print 'bar called!'
def Ramp(result, size, start, end):
step = (end-start)/(size-1)
for i in xrange(size):
result[i] = start + step*i
def RampNum(result, size, start, end):
tmp = zeros(size+1)
step = (end-start)/(size-1-tmp)
result[:] = arange(size)*step + start
def main():
#print 'hi'
size = 6
reps = 5
print 'reps:',reps
array_normal = [0]*size
for i in xrange(reps): # <<<<< ERROR (fork instead of for)
Ramp(array_normal, size, 0.0, 1.0)
Rtime = time.clock()-t0
#print 'Ramp time:', Rtime
array_num = zeros(size,'d')
for i in xrange(reps):
RampNum(array_num, size, 0.0, 1.0)
RNtime = time.clock()-t0
print 'RampNum time:', RNtime
print 'speedup:',Rtime/RNtime
if __name__ == '__main__':
x = 'hi'
g2='another global'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment