Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- from numpy import *
- import matplotlib
- matplotlib.use("TKAgg", False)
- import pylab
- import os, warnings, time, random
- def F(f,x):
- x=numpy.array(x)
- return eval(f)
- def isZero(x,lim=1E-16):
- return x is None or abs(x)<=lim
- __scrub_nums = '0123456789'
- def scrub(f):
- nf=''
- for i in range(len(f)):
- nf += f[i]
- if f[i] in __scrub_nums:
- if i+1 < len(f) and f[i+1] != '.' and f[i+1] not in __scrub_nums:
- nf += '.0'
- elif i+1 == len(f):
- nf +='.0'
- return nf
- def JDraw(pause = .001):
- """Any pause < .001 = .001"""
- pylab.draw()
- warnings.simplefilter("ignore")
- pylab.gcf().canvas.start_event_loop(timeout = pause)
- warnings.simplefilter("always")
- def rebound(x,f,p=10):
- xr=max(x)-min(x)
- fr=max(f)-min(f)
- dx=xr/100.*p
- df=fr/100.*p
- xmin=min(x)-.5*dx
- xmax=max(x)+.5*dx
- fmin=min(f)-.5*df
- fmax=max(f)+.5*df
- return (xmin,xmax,fmin,fmax)
- def qjplot(x,f,*args,**kwargs):
- pylab.ion()
- do_rebound = kwargs.pop('rebound',0)
- pylab.plot(x,f,*args,**kwargs)
- if do_rebound:
- (xmin,xmax,fmin,fmax)=rebound(x,f)
- pylab.xlim(xmin,xmax)
- pylab.ylim(fmin,fmax)
- def qjclf():
- pylab.clf()
- def qjwait():
- raw_input("Press enter to continue: ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement