rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print len(fft), len(self.weights)
def chainfunc(self, pad, buffer): gst.log ("Passing buffer with ts %d" % (buffer.timestamp))
print "done"
def chainfunc(self, pad, buffer): gst.log ("Passing buffer with ts %d" % (buffer.timestamp))
def test_finditer_ignore_case(self): s = self._swrap finditer = self._build_ignore_case('a', 'b', 'c', 'd').finditer self.assertEquals( sorted(finditer(s('AaBbCcDd'))), self._result([('a', 0), ('a', 1), ('b', 2), ('b', 3), ('c', 4), ('c', 5), ('d', 6), ('d', 7)])) def test_finditer_ignore_case_redundant(self): s = sel...
def test_finditer_overlap(self): s = self._swrap finditer = self._build('a', 'ab', 'abc', 'abcd').finditer self.assertEquals( sorted(finditer(s('abcd'))), self._result([('a', 0), ('ab', 0), ('abc', 0), ('abcd', 0)])) def test_finditer_reverse_overlap(self): s = self._swrap finditer = self._build('d', 'cd', 'bcd', 'abc...
def test_finditer_ignore_case(self): s = self._swrap finditer = self._build_ignore_case('a', 'b', 'c', 'd').finditer self.assertEquals( sorted(finditer(s('AaBbCcDd'))), self._result([('a', 0), ('a', 1), ('b', 2), ('b', 3), ('c', 4), ('c', 5), ('d', 6), ('d', 7)]))
def test_finditer_overlap(self): s = self._swrap finditer = self._build('a', 'ab', 'abc', 'abcd').finditer self.assertEquals( sorted(finditer(s('abcd'))), self._result([('a', 0), ('ab', 0), ('abc', 0), ('abcd', 0)])) def test_finditer_reverse_overlap(self): s = self._swrap finditer = self._build('d', 'cd', 'bcd', 'abc...
def test_finditer_overlap(self): s = self._swrap finditer = self._build('a', 'ab', 'abc', 'abcd').finditer self.assertEquals( sorted(finditer(s('abcd'))), self._result([('a', 0), ('ab', 0), ('abc', 0), ('abcd', 0)]))
def test_filelike_searching(self): data = BytesIO(self.search_string)
def _search_in_file(self, ac, data): import tempfile tmp = tempfile.TemporaryFile() try: tmp.write(data.encode('ASCII')) tmp.seek(0) return list(ac.filefind(tmp)) finally: tmp.close() def test_large_filelike_searching(self):
def test_filelike_searching(self): data = BytesIO(self.search_string) filefind = self._build('SADHFCAL'.encode('ASCII'), 'bdeg'.encode('ASCII')).filefind
self.assertEquals(len(list(filefind(data))), 6000)
data = BytesIO(self.search_string) result = list(filefind(data)) self.assertEquals(len(result), 6000) def test_large_filelike_searching_check(self): ac = self._build(*self.simple_kwds) data = BytesIO(self.simple_data) result = list(ac.filefind(data)) self.assertEquals(result, self.expected_result) def test_file_searc...
def test_filelike_searching(self): data = BytesIO(self.search_string) filefind = self._build('SADHFCAL'.encode('ASCII'), 'bdeg'.encode('ASCII')).filefind
if inputt < len(stims) and t*TR/DIVIDER > stims[inputt][0]:
if inputt < len(stims) and t*TR/DIVIDER+SHIFT*TR > stims[inputt][0]:
def sim(stims, params, TR, num): TR = float(TR) out = [0 for i in range(0, num)] inputl = 0; inputt = 0 statevars = State() stopt = num*TR/DIVIDER for t in range(0, num*DIVIDER): if inputt < len(stims) and t*TR/DIVIDER > stims[inputt][0]: inputl = stims[inputt][1] inputt = inputt+1 statevars = transition(statevars, par...
exp_init = sim(stims, getparams_mu(0,histimg), TR, actual.get_header()['dim'][4])
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
mode_init = sim(stims, getparams_mode(0, histimg), TR, actual.get_header()['dim'][4])
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
print len(exp_init)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
print len(mode_init)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
P.plot([i*TR for i in range(len(exp_init))], exp_init)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
P.plot([i*TR for i in range(len(mode_init))], mode_init)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
leg.extend(["I_mu", "F_mu", "I_mod", "F_mod"])
leg.extend(["FinalMu", "FinalMod"]) P.legend(leg)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
P.legend(leg)
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
cmake_install_dir = cmakeinst(depdir, depprefix, "cmake", CMAKE_URL)
cmake_install_dir = confmakeinst(depdir, depprefix, "cmake", CMAKE_URL)
def progress(blocks, blocksize, total): ESC = chr(27); sys.stdout.write(ESC + '[2K' + ESC+'[G') text = " %i of %i bytes (%.0f percent) complete" % (blocks*blocksize, total, float(blocks*blocksize*100)/total) sys.stdout.write(text + '\x08'*len(text)) sys.stdout.flush()
upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2
upper = source.get_data()[0,0,0,time,pp, -2] lower = source.get_data()[0,0,0,time,pp, -3] count = source.get_header()['dim'][6] - 3
def getparams_mode(time, source): params = [0 for i in range(0,7)] for pp in range(0, 7): upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2 width = (upper-lower)/count print lower, upper, width, count histinput = [[] for j in range(0, his...
histinput = [[] for j in range(0, histimg.get_header()['dim'][6]-2)] for j in range(0, histimg.get_header()['dim'][6]-2):
histinput = [[] for j in range(0, histimg.get_header()['dim'][6]-3)] for j in range(0, histimg.get_header()['dim'][6]-3):
def getparams_mode(time, source): params = [0 for i in range(0,7)] for pp in range(0, 7): upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2 width = (upper-lower)/count print lower, upper, width, count histinput = [[] for j in range(0, his...
upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2
upper = source.get_data()[0,0,0,time,pp, -2] lower = source.get_data()[0,0,0,time,pp, -3] count = source.get_header()['dim'][6] - 3
def getparams_mu(time, source): params = [0 for i in range(0,7)] for pp in range(0, 7): upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2 width = (upper-lower)/count total = 0 params[pp] = 0 print lower, upper, width, count for j in range...
for j in range(0, histimg.get_header()['dim'][6]-2):
for j in range(0, histimg.get_header()['dim'][6]-3):
def getparams_mu(time, source): params = [0 for i in range(0,7)] for pp in range(0, 7): upper = source.get_data()[0,0,0,time,pp, -1] lower = source.get_data()[0,0,0,time,pp, -2] count = source.get_header()['dim'][6] - 2 width = (upper-lower)/count total = 0 params[pp] = 0 print lower, upper, width, count for j in range...
print "Usage: ", sys.argv[0], "<InDir>"
print "Usage: ", sys.argv[0], "<InDir> [param number]"
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
upper = histimg.get_data()[0,0,0,t,param, -1] lower = histimg.get_data()[0,0,0,t,param, -2] count = histimg.get_header()['dim'][6] - 2
upper = histimg.get_data()[0,0,0,t,param, -2] lower = histimg.get_data()[0,0,0,t,param, -3] count = histimg.get_header()['dim'][6] - 3
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
print histimg.get_data()[0,0,0,t, param, 0:-2] histinput = [[] for j in range(0, histimg.get_header()['dim'][6]-2)] for j in range(0, histimg.get_header()['dim'][6]-2):
print histimg.get_data()[0,0,0,t, param, 0:-3] histinput = [[] for j in range(0, histimg.get_header()['dim'][6]-3)] for j in range(0, histimg.get_header()['dim'][6]-3):
def HRF(stims, TR, num): TR = float(TR) inputl = 0; inputt = 0 dt = TR/HRFDIVIDER stimarr = [i for i in range(0, int(num*HRFDIVIDER + 2*hrfparam[6]/dt))] for i in range(0, len(stimarr)): if inputt < len(stims) and i*dt > stims[inputt][0] + hrfparam[5]\ + hrfparam[6]: inputl = stims[inputt][1] inputt = inputt+1 stimarr[...
if dir == 'x-y': data = [images[0].get_data()[:,i,slnum,time] for i in range(images[0].get_shape()[1])] elif dir == 'y-z': data = [images[0].get_data()[slnum,:,i,time] for i in range(images[0].get_shape()[2])] elif dir == 'x-z': data = [images[0].get_data()[:,slnum,i,time] for i in range(images[0].get_shape()[2])]
try: if dir == 'x-y': data = [images[0].get_data()[:,i,slnum,time] for i in range(images[0].get_shape()[1])] elif dir == 'y-z': data = [images[0].get_data()[slnum,:,i,time] for i in range(images[0].get_shape()[2])] elif dir == 'x-z': data = [images[0].get_data()[:,slnum,i,time] for i in range(images[0].get_shape()[2])]...
def imshowslice(dir, slnum, time): if dir == 'x-y': data = [images[0].get_data()[:,i,slnum,time] for i in range(images[0].get_shape()[1])] elif dir == 'y-z': data = [images[0].get_data()[slnum,:,i,time] for i in range(images[0].get_shape()[2])] elif dir == 'x-z': data = [images[0].get_data()[:,slnum,i,time] for i in ra...
valfmt='%3i') axtime = pylab.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor) g_timeSlide = Slider(axtime, 'Time', 0 , images[0].get_shape()[3]-1, valinit=0, \
def imshowslice(dir, slnum, time): if dir == 'x-y': data = [images[0].get_data()[:,i,slnum,time] for i in range(images[0].get_shape()[1])] elif dir == 'y-z': data = [images[0].get_data()[slnum,:,i,time] for i in range(images[0].get_shape()[2])] elif dir == 'x-z': data = [images[0].get_data()[:,slnum,i,time] for i in ra...
def timecall(val): global g_sliceSlide global g_dir imshowslice(g_dir, g_sliceSlide.val, val) pylab.draw()
def slicecall(val): global g_dir global g_timeSlide imshowslice(g_dir, val, g_timeSlide.val) pylab.draw()
g_timeSlide.on_changed(timecall)
def timecall(val): global g_sliceSlide global g_dir imshowslice(g_dir, g_sliceSlide.val, val) pylab.draw()
SHIFT=4
SHIFT=0
def processHistos(image, pos, p): out = [[] for t in range(0, image.get_header()['dim'][4])] #generate the histogram for measurements for t in range(0, image.get_header()['dim'][4]): upper = image.get_data()[pos[0],pos[1],pos[2],t,p, -2] lower = image.get_data()[pos[0],pos[1],pos[2],t,p, -3] count = image.get_header()[...
elif len(sys.argv) != 2:
elif len(sys.argv) == 2: param = PARAM pos = (0,0,0); else:
def processHistos(image, pos, p): out = [[] for t in range(0, image.get_header()['dim'][4])] #generate the histogram for measurements for t in range(0, image.get_header()['dim'][4]): upper = image.get_data()[pos[0],pos[1],pos[2],t,p, -2] lower = image.get_data()[pos[0],pos[1],pos[2],t,p, -3] count = image.get_header()[...
os.symlink(FILENAME + file, newname);
os.symlink(FILENAME + file, file);
def buildboost(basedir, instdir, name, url): FILENAME = "./boost-1.41.0/" topdir = os.getcwd() print "building %s" % name instdir = cmakeinst(basedir, instdir, name, url) print "build of %s completed" % name os.chdir(join(instdir, "lib")); for file in os.listdir(FILENAME): newname = file.split("-mt") newname = "".join...
mpi_install_dir = confmakeinst(depdir, depprefix, "mpi", OPENMPI_URL)
if mpi_install_dir == "": mpi_install_dir = confmakeinst(depdir, depprefix, "mpi", OPENMPI_URL)
def progress(blocks, blocksize, total): ESC = chr(27); sys.stdout.write(ESC + '[2K' + ESC+'[G') text = " %i of %i bytes (%.0f percent) complete" % (blocks*blocksize, total, float(blocks*blocksize*100)/total) sys.stdout.write(text + '\x08'*len(text)) sys.stdout.flush()
pylab.imshow(data,cmap='gray', origin='lower')
pylab.imshow(data,cmap='gray', origin='lower', interpolation='nearest')
def imshowslice(dir, slnum, time): if dir == 'x-y': data = [images[0].get_data()[:,i,slnum,time] for i in range(images[0].get_shape()[1])] elif dir == 'y-z': data = [images[0].get_data()[slnum,:,i,time] for i in range(images[0].get_shape()[2])] elif dir == 'x-z': data = [images[0].get_data()[:,slnum,i,time] for i in ra...
print url
def cmakeinst(basedir, instdir, name, url, defstrings = "", src_dir = ""): topdir = os.getcwd() if src_dir == "": src_dir = getep(basedir,name,url)
itk_install_dir = cmakeinst(depdir, depprefix, "itk", ITK_URL, ("-DITK_USE_REVIEW=ON", "-DBUILD_TESTING=OFF", "-DBUILD_EXAMPLES=OFF"))
itk_install_dir = cmakeinst(depdir, depprefix, "itk", ITK_URL, defstrings=("-DITK_USE_REVIEW=ON", "-DBUILD_TESTING=OFF", "-DBUILD_EXAMPLES=OFF"))
def progress(blocks, blocksize, total): ESC = chr(27); sys.stdout.write(ESC + '[2K' + ESC+'[G') text = " %i of %i bytes (%.0f percent) complete" % (blocks*blocksize, total, float(blocks*blocksize*100)/total) sys.stdout.write(text + '\x08'*len(text)) sys.stdout.flush()
dysii_install_dir = cmakeinst(srcpath+"/external/", depprefix, "dysii", "", ("-DGSL=%s" % gsl_install_dir, \ "-DMPI=%s" % mpi_install_dir, "-DBOOST=%s" % boost_install_dir), srcpath+"/external/dysii")
dysii_install_dir = cmakeinst(srcpath+"/external/", depprefix, "dysii", "", defstrings=("-DGSL=%s" % gsl_install_dir, \ "-DMPI=%s" % mpi_install_dir, "-DBOOST=%s" % boost_install_dir), src_dir=srcpath+"/external/dysii")
def progress(blocks, blocksize, total): ESC = chr(27); sys.stdout.write(ESC + '[2K' + ESC+'[G') text = " %i of %i bytes (%.0f percent) complete" % (blocks*blocksize, total, float(blocks*blocksize*100)/total) sys.stdout.write(text + '\x08'*len(text)) sys.stdout.flush()
P.plot([val[0] for val in stims], [.005*val[1] - .01 for val in stims], 'r')
def processHistos(image, pos, p): out = [[] for t in range(0, image.get_header()['dim'][4])] #generate the histogram for measurements for t in range(0, image.get_header()['dim'][4]): upper = image.get_data()[pos[0],pos[1],pos[2],t,p, -2] lower = image.get_data()[pos[0],pos[1],pos[2],t,p, -3] count = image.get_header()[...
dt = images[i].get_header()['pixdim'][4]
if images[i].get_header()['pixdim'][4] > 0: dt = images[i].get_header()['pixdim'][4] else: dt = 2.1
def mousecall(event): global g_dir global g_sliceSlide if event.inaxes == ax and event.button == 1: figplot = pylab.figure() print g_dir if g_dir == 'y-z': x = int(g_sliceSlide.val) y = int(event.ydata) z = int(event.xdata) elif g_dir == 'x-z': x = int(event.ydata) y = int(g_sliceSlide.val) z = int(event.xdata) else: #...
parameters[i].sigma = sigma * hessianInv[i,i]
parameters[i].sigma = sigma * math.sqrt(hessianInv[i,i])
def calcHessianJtrA(dc, c, y): """ Hessian matrix = square matrix of secnd order partial derivatives c = matrix of concentrations of various components (depends on parameter count) """ ct = c.T ctc = numpy.matlib.dot(ct, c) ctcinv = ctc.I aux = numpy.matlib.dot(ctcinv, ct) a = numpy.matlib.dot(aux, y) aux = numpy.matli...
self.loadFile(self.sender().data().toString())
self.parent().loadFile(self.sender().data().toString())
def openRecentFile(self): if self.sender(): self.loadFile(self.sender().data().toString())
mu = 1e-4
mu = 1e-6
def ngml2(self, p, p_firstOrder, p_fixed, time, absorbance, logger): """ Calculates the fit, residuals, and reaction rate coefficients from absorbance values.
ctc = matlib.dot(c.T, c)
ct = c.T ctc = matlib.dot(ct, c)
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
aux = matlib.dot(ctcinv, c.T)
aux = matlib.dot(ctcinv, ct)
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
j = matlib.empty([dc[0].shape[0], len(dc)])
j = matlib.zeros([dc[0].shape[0], len(dc)])
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
dct = dc[p].T dctc = matlib.dot(dct, c)
dctc = matlib.dot(dc[p].T, c)
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
hessian = matlib.dot(j.T, j) jtr = matlib.dot(j.T, r)
hessian += matlib.dot(j.T, j) jtr += matlib.dot(j.T, r)
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
c = matlib.empty([len(time), matlib.size(p)])
c = matlib.zeros([len(time), matlib.size(p)])
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
dci = matlib.empty([len(time), matlib.size(p)])
dci = matlib.zeros([len(time), matlib.size(p)])
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
for i in range(0, matlib.size(p)):
for i in range(0, hessian.shape[0]):
def calcHessianJtrA(dc, c, y): ctc = matlib.dot(c.T, c) ctcinv = ctc.I aux = matlib.dot(ctcinv, c.T) a = matlib.dot(aux, y) aux = matlib.dot(c, a) r = aux - y ssq = 0 for i in range(0, r.shape[0]): for j in range(0, r.shape[1]): ssq += r[i,j] * r[i,j] j = matlib.empty([dc[0].shape[0], len(dc)]) dq = [] for p in range(0...
[True, False])
[True, True])
def getInitialParameters(self, time): return ([10 / (time[len(time) / 2] - time[0]), 3 / (time[len(time) / 2] - time[0])], [True, False])
c = a_0 * matlib.exp(-k[0,0] * t)
c0 = a_0 * matlib.exp(-k[0,0] * t) c1 = a_0 * matlib.exp(-k[1,0] * t) c = matlib.hstack((c0, c1))
def rcalc(self, k, a_0, t, y): """ Function used by ngml, but not by ngml2. Parameter k (=parameter) is a column vector. Parameter a_0 is a number. Parameter t is a list of time values. Parameter y is a column vector of measured values. Returns tuple of three values: - first value is a list of residuals 'r' - second va...
class ModelFirst2(BaseModel): name = u"A→B, C→D" def getInitialParameters(self, time): return ([10 / (time[len(time) / 2] - time[0]), 3 / (time[len(time) / 2] - time[0])], [True, True]) def rcalc(self, k, a_0, t, y): """ Function used by ngml, but not by ngml2. Parameter k (=parameter) is a column vector. Parameter a...
def rcalc(self, k, a_0, t, y): """ Function used by ngml, but not by ngml2. Parameter k (=parameter) is a column vector. Parameter a_0 is a number. Parameter t is a list of time values. Parameter y is a column vector of measured values. Returns tuple of three values: - first value is a list of residuals 'r' - second va...
if getattr(_runtime_conf.app, 'reload', False) is True:
if getattr(_runtime_conf, 'app', None) and getattr(_runtime_conf.app, 'reload', False) is True:
def __init__(self, root, renderers = renderers, default_renderer = 'kajiki', template_path = 'templates', hooks = []): self.root = root self.renderers = renderers self.default_renderer = default_renderer self.hooks = hooks self.template_path = template_path Monito...
if param_name in argspec.args:
if param_name in argspec[0]:
def get_params(self, all_params, remainder, argspec, im_self): valid_params = dict() positional_params = [] if im_self is not None: positional_params.append(im_self) # handle params that are POST or GET variables first for param_name, param_value in all_params.iteritems(): if param_name in argspec.args: valid_params[...
if 'test_config' not in sys.path: sys.path.append(os.path.abspath('test_config'))
test_config_d = os.path.join(os.path.dirname(__file__), 'test_config') if test_config_d not in sys.path: sys.path.append(test_config_d)
def setUp(self): import sys import os if 'test_config' not in sys.path: sys.path.append(os.path.abspath('test_config'))
from pecan import conf, set_config set_config('config')
conf = configuration.initconf() conf.update_with_module('config')
def test_update_set_config(self): """Update an empty configuration with the default values""" from pecan import conf, set_config set_config('config')
from pecan import conf, set_config set_config('empty')
conf = configuration.initconf() conf.update_with_module('empty')
def test_update_set_default_config(self): """Update an empty configuration with the default values""" from pecan import conf, set_config set_config('empty')
class SubSubRootController(object): @expose('json') def index(self): redirect('/sub/deeper/not_empty', internal=True) @expose('json') def not_empty(self, data): return data class SubRootController(object): @expose('json') def index(self): return '/sub' deeper = SubSubRootController()
def test_simple_failure(self): class RegistrationSchema(Schema): first_name = validators.String(not_empty=True) last_name = validators.String(not_empty=True) email = validators.Email() username = validators.PlainText() password = validators.String() password_confirm =...
sub = SubRootController()
def index(self): return '/sub'
app = TestApp(make_app(RootController())) resp = app.post('/sub/deeper', dumps({'name':'foobar'})) assert resp.body != {}
def json_with_handler(self, data): assert request.validation_error is not None return 'Success!'
hdr_file.write('_init_functions[0] = {}')
hdr_file.write('_init_functions[0] = {};')
hdr_file.write('\n\ntypedef int (*pt2Function)(void);\n')
all_modules = enabled_modules + list(disabled_modules)
if not disabled_modules: all_modules = enabled_modules else: all_modules = enabled_modules + disabled_modules
def create_makefile_modules(file_path, module_info, disabled_modules, applications, compile_type): makefile_modules = open(file_path, 'w') enabled_modules = module_info.keys() all_modules = enabled_modules + list(disabled_modules) if 'all' == compile_type: compile_modules = all_modules elif 'enabled' == compile_type...
disabled_modules = disabled_modules.rsplit(' ') (applications, compile_type, disabled_modules) = parse_info_file(INFO_FILE_PATH, disabled_modules)
if disabled_modules: disabled_modules = disabled_modules.rsplit(' ') (applications, compile_type, disabled_modules) = parse_info_file(os.path.join(srcdir, INFO_FILE_NAME), disabled_modules)
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
create_makefile_modules(os.path.join(srcdir, 'Makefile.modules'),
create_makefile_modules('Makefile.modules',
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
hdr_file.write('\n\nconst char *modules_' + current_app) hdr_file.write('[0] = {};')
hdr_file.write('\n\ntypedef int (*pt2Function)(void);\n')
module_info = read_module_info(MODULES_DIR,
module_info = read_module_info(os.path.join(srcdir, MODULES_DIR),
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
def create_makefile_modules(srcdir, module_info, disabled_modules): file_path = 'Makefile.modules' makefile_modules = open(file_path, 'w') makefile_modules.write(' for current in module_info.keys(): path = os.path.join(srcdir, MODULES_DIR, current, 'Makefile.am') makefile_modules.write('include ' + path + '\n') mak...
hdr_file.write('#ifndef ' + app_string + '\n')
create_makefile_modules(srcdir, module_info, disabled_modules)
def main(): srcdir = None disabled_modules = None applications = set(['hipd']) try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules...
def create_header_files(output_dir, suffix, applications, includes, init_functions):
def create_header_files(output_dir, suffix, applications, includes, init_functions, enabled_modules):
def create_header_files(output_dir, suffix, applications, includes, init_functions): if False == os.path.isdir(output_dir): os.mkdir(output_dir) for current_app in applications.keys(): hdr_file_path = os.path.join(output_dir, current_app + suffix) try: hdr_file = open(hdr_file_path, 'w') try: app_string = 'HIP_' + ...
hdr_file.write(num_modules + ';')
hdr_file.write(num_modules + ';\n') hdr_file.write('\nconst char *modules_' + current_app + '[') hdr_file.write(num_modules + '] = {') first_loop = True for module in enabled_modules: if first_loop != True: hdr_file.write(', ') hdr_file.write('"' + module + '"') first_loop = False hdr_file.write('};')
hdr_file.write('\n\ntypedef int (*pt2Function)(void);\n')
init_functions)
init_functions, module_info.keys())
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
else:
elif not self.str_is_lsi(addr):
def reread(self): f = file(self.hostsfile) d = {} aaaa_hit = {} aaaa = {} a = {} while 1: l = f.readline() if not l: break l = l.strip() if not l or l.startswith('#'): continue aa = l.split() addr = aa.pop(0) for n in aa: n = self.sani(n) a2 = n.split('.') if len(a2) <= 1: for s in self.suffixes: d['%s.%s' % (n,s)] = a...
def parse_module_info(path, applications, required_modules):
def parse_module_info(path, required_modules):
def parse_module_info(path, applications, required_modules): file = open(path, "r") dom = xml.dom.minidom.parse(file) file.close() module_info = {} module_name = str(dom.getElementsByTagName('module')[0].attributes['name'].value) module_info['version'] = str(dom.getElementsByTagName('module')[0].attributes['version'...
applications.add(name)
def parse_module_info(path, applications, required_modules): file = open(path, "r") dom = xml.dom.minidom.parse(file) file.close() module_info = {} module_name = str(dom.getElementsByTagName('module')[0].attributes['name'].value) module_info['version'] = str(dom.getElementsByTagName('module')[0].attributes['version'...
return (applications, module_name, module_info, required_modules)
return (module_name, module_info, required_modules)
def parse_module_info(path, applications, required_modules): file = open(path, "r") dom = xml.dom.minidom.parse(file) file.close() module_info = {} module_name = str(dom.getElementsByTagName('module')[0].attributes['name'].value) module_info['version'] = str(dom.getElementsByTagName('module')[0].attributes['version'...
applications = set()
def read_module_info(MODULES_DIR, disabled_modules): # Initialize output variable module_info = {} required_modules = set() applications = set() # Iterate through all sub directories in MODULES_DIR for current_module in glob.glob(MODULES_DIR + '/*/'): cont = False print '| found module: ' + current_module # Check ...
(applications, module_name, info, required_modules) = parse_module_info(path, applications, required_modules)
(module_name, info, required_modules) = parse_module_info(path, required_modules)
def read_module_info(MODULES_DIR, disabled_modules): # Initialize output variable module_info = {} required_modules = set() applications = set() # Iterate through all sub directories in MODULES_DIR for current_module in glob.glob(MODULES_DIR + '/*/'): cont = False print '| found module: ' + current_module # Check ...
return (applications, module_info, required_modules)
return (module_info, required_modules)
def read_module_info(MODULES_DIR, disabled_modules): # Initialize output variable module_info = {} required_modules = set() applications = set() # Iterate through all sub directories in MODULES_DIR for current_module in glob.glob(MODULES_DIR + '/*/'): cont = False print '| found module: ' + current_module # Check ...
hdr_file.write('};') hdr_file.write('\n\n') init_function_string = 'static int (*' + current_app init_function_string += '_init_functions[' + num_modules init_function_string += '])(void) = {'
hdr_file.write('};\n\n')
hdr_file.write('#ifndef ' + app_string + '\n')
(applications, module_info, required_modules) = read_module_info(os.path.join(srcdir, MODULES_DIR), disabled_modules)
(module_info, required_modules) = read_module_info(os.path.join(srcdir, MODULES_DIR), disabled_modules)
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
create_makefile_modules('Makefile.modules',
create_makefile_modules(os.path.join(srcdir, 'Makefile.modules'),
def main(): srcdir = None disabled_modules = None try: opts, args = getopt.getopt(sys.argv[1:], "s:d:", ["srcdir=", "disabled_modules="]) except getopt.GetoptError, err: print str(err) sys.exit(2) for o, a in opts: if o in ("-s", "--srcdir"): srcdir = a elif o in ("-d", "--disabled_modules"): disabled_modules = a else...
def parse_search_html(lang_id, search, start):
def parse_search_html(lang_id, msgctxt, msgid, start):
def parse_search_html(lang_id, search, start): param = urlencode( { 'show' : 'all', \ 'search' : search, \ 'start' : start } ) url = 'https://translations.launchpad.net/bleachbit/trunk/+pots/bleachbit/%s/+translate?%s' \ % (lang_id, param) print 'debug: fetch url %s ' % url doc = urlopen(url).read() soup = BeautifulSou...
'search' : search, \
'search' : msgid, \
def parse_search_html(lang_id, search, start): param = urlencode( { 'show' : 'all', \ 'search' : search, \ 'start' : start } ) url = 'https://translations.launchpad.net/bleachbit/trunk/+pots/bleachbit/%s/+translate?%s' \ % (lang_id, param) print 'debug: fetch url %s ' % url doc = urlopen(url).read() soup = BeautifulSou...
div = tr.find('div', attrs={'id' : re.compile("^msgset_[0-9]+_")}) english = div.text
en_div = tr.find('div', attrs={'id' : re.compile("^msgset_[0-9]+_")}) en_txt = en_div.text en_div_id = [x[1] for x in en_div.attrs if x[0]=='id'][0] en_ctxt_div = soup.findAll(id = en_div_id.replace('singular', 'context')) if en_ctxt_div: en_ctxt = en_ctxt_div[0].text else: en_ctxt = "none"
def parse_search_html(lang_id, search, start): param = urlencode( { 'show' : 'all', \ 'search' : search, \ 'start' : start } ) url = 'https://translations.launchpad.net/bleachbit/trunk/+pots/bleachbit/%s/+translate?%s' \ % (lang_id, param) print 'debug: fetch url %s ' % url doc = urlopen(url).read() soup = BeautifulSou...
translations[lang_id][english] = href
if not en_ctxt in translations[lang_id].keys(): translations[lang_id][en_ctxt] = {} translations[lang_id][en_ctxt][en_txt] = href
def parse_search_html(lang_id, search, start): param = urlencode( { 'show' : 'all', \ 'search' : search, \ 'start' : start } ) url = 'https://translations.launchpad.net/bleachbit/trunk/+pots/bleachbit/%s/+translate?%s' \ % (lang_id, param) print 'debug: fetch url %s ' % url doc = urlopen(url).read() soup = BeautifulSou...
if msgctxt: raise RuntimeError('msgctxt not suppirted')
def who_translated(lang_id, msgctxt, msgid): """Returns name of person who translated a particular string""" if not lang_id in translations.keys(): # initialize the language translations[lang_id] = {} if msgctxt: raise RuntimeError('msgctxt not suppirted') start = 0 while True: start = parse_search_html(lang_id, msg...
start = parse_search_html(lang_id, msgid, start) msgid2 = msgid.replace('\n', '') if translations[lang_id].has_key(msgid2): url = translations[lang_id][msgid2] return parse_detail_html(url)
start = parse_search_html(lang_id, msgctxt, msgid, start) msgid2 = msgid.replace('\n', '').rstrip() msgctxt_key = "none" if msgctxt == None else msgctxt if translations[lang_id].has_key(msgctxt_key): if translations[lang_id][msgctxt_key].has_key(msgid2): url = translations[lang_id][msgctxt_key][msgid2] return parse_det...
def who_translated(lang_id, msgctxt, msgid): """Returns name of person who translated a particular string""" if not lang_id in translations.keys(): # initialize the language translations[lang_id] = {} if msgctxt: raise RuntimeError('msgctxt not suppirted') start = 0 while True: start = parse_search_html(lang_id, msg...
set=Operation("set", Entity(self.target, status=new_status), to=target) res.append(set) if new_status < 0:
if new_status < 0.1: new_status = -1
def tick_operation(self, op): """ Op handler for regular tick op """ # print "Sharpen.tick" res=Oplist()
else: self.progress += 0.1
def tick_operation(self, op): """ Op handler for regular tick op """ # print "Dig.tick" target = server.world.get_object(self.target) world = target.location.parent if not target: print "Target is no more" self.irrelevant() return
mapeditor.send(Operation("wield", Entity(axe.id), to=settler)) mapeditor.send(Operation("use", Operation("cut", Entity(oak.id)), to=settler))
m.m.send(Operation("wield", Entity(axe.id), to=settler)) m.m.send(Operation("use", Operation("cut", Entity(oak.id)), to=settler))
def test_task(host='', account='', password='', **args): m=create_editor(host, account, password) settler=m.make('settler',pos=(1,1,0)) axe=m.make('axe',pos=(0,0,0),parent=settler.id) oak=m.make('oak',pos=(5,0,0)) mapeditor.send(Operation("wield", Entity(axe.id), to=settler)) mapeditor.send(Operation("use", Operation...
self.editor.m.send(Operation('wield', Entity(t.id), to=c)) self.editor.m.send(Operation('use', Operation(op, Entity(o.id)), to=c))
self.editor.avatar.send(Operation('wield', Entity(t.id), to=c)) self.editor.avatar.send(Operation('use', Operation(op, Entity(o.id)), to=c))
def test_task(self, task, target, tool, op, avatar = 'settler'): "Test activating a task using a tool on a target" if type(avatar)== StringType: c = self.create_character(avatar, self.get_pos()) else: c = avatar
else: self.progress += 0.1
def tick_operation(self, op): """ Op handler for regular tick op """ # print "Delve.tick"
new_status = target.status - 0.1
new_status = 1 if hasattr(target, 'status'): new_status = target.status - 0.1
def tick_operation(self, op): """ Op handler for regular tick op """ # print "Sharpen.tick" res=Oplist()
/!\ (THIS IS BUGGY : for the moment we erase most of accepted_between_arguments inside A,B and C. The consequence is that as_written is wrong) /!\ """
"""
def SearchArguments(s,number_of_arguments): r""" From a string of the form {A}...{B}...{C}, returns the list ["A","B","C"] where the dots are elements of the list accepted_between_arguments. Inside A,B and C you can have anything including the elements of the list accepted_between_arguments. It is important that the st...
if s[turtle:turtle+len(macro_name)+1] == "\\"+macro_name :
if s[turtle:turtle+len(macro_name)] == macro_name :
def NextMacroCandidate(s,macro_name): turtle = 0 while turtle < len(s): if s[turtle:turtle+len(macro_name)+1] == "\\"+macro_name : return True,turtle if s[turtle]=="%": a=s[turtle:] pos = a.find("\n") if pos == -1: return False,-1 turtle = turtle+pos turtle=turtle+1
def SearchUseOfMacro(code,name,number_of_arguments=None):
def SearchUseOfMacro(code,macro_name,number_of_arguments=None):
def NextMacroCandidate(s,macro_name): turtle = 0 while turtle < len(s): if s[turtle:turtle+len(macro_name)+1] == "\\"+macro_name : return True,turtle if s[turtle]=="%": a=s[turtle:] pos = a.find("\n") if pos == -1: return False,-1 turtle = turtle+pos turtle=turtle+1
name is the name of the macro to be fitted like \MyMacro (including the backslash).
macro_name is the name of the macro to be fitted like \MyMacro (including the backslash). /!\ We do not manage the case where the first argument is not immediatly after the macro name, i.e. \MyMacro {argument} (with a space between \MyMacro and the first opening bracket) will be buggy.
def SearchUseOfMacro(code,name,number_of_arguments=None): r""" number_of_arguments is the number of arguments expected. Giving a too large number produces wrong results in the following example case where \MyMacro is supposed to have 3 arguments : \MyMacro{A}{B}{C} {\bf An other text} The {\bf ...} group is not a param...
remaining = code.text_brut while name in remaining : turtle =
s = code.text_brut remaining = s use = [] while macro_name in remaining : remaining=s[turtle:] boo,offset = NextMacroCandidate(remaining,macro_name) if boo==False: return use if boo : turtle = turtle+offset+len(macro_name) remaining=s[turtle:] arguments,as_written=SearchArguments(remaining,number_of_arguments) occurren...
def SearchUseOfMacro(code,name,number_of_arguments=None): r""" number_of_arguments is the number of arguments expected. Giving a too large number produces wrong results in the following example case where \MyMacro is supposed to have 3 arguments : \MyMacro{A}{B}{C} {\bf An other text} The {\bf ...} group is not a param...
r
def SearchArguments(remaining,number_of_arguments): """ From a string of the form {A}{B}{C}, returns the list ["A","B","C"]. """ next_can_be_open = compactization(remaining,accepted_between_arguments)[0] still_to_be_done = True arguments = [] as_written = "" # We will put in that variable the precise text that appears...
def __init__(self,a=None): if not a : a={} dict.__init__(a) def read_code(self,codeLaTeX,magic_macro):
def __init__(self,name): dict.__init__({}) self.name=name self.feed_macro="\\Feed"+self.name self.put_macro="\Put"+self.name def feed(self,codeLaTeX):
def __init__(self,a=None): if not a : a={} dict.__init__(a)
magic_macro is a macro name which is supposed to have 2 arguments. Example with magic_macro = \MyMacro \MyMacro{thislabel}{This is my \LaTeX\ code} will add the code «This is my \LaTeX\ code» in the dictionary with the key «thislabel» """ liste_occurrences = codeLaTeX.search_use_of_macro(magic_macro,2)
Example If self.name is "mydict", codeLaTeX is parsed. Let consider the following line : \feed_mydict{thislabel}{This is my \LaTeX\ code} will add the code «This is my \LaTeX\ code» in the dictionary with the key «thislabel» """ liste_occurrences = codeLaTeX.search_use_of_macro(self.feed_macro,2)
def read_code(self,codeLaTeX,magic_macro): r""" Read the code and fill the dictionary.