rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
FILE.write(repr(self.d.upTotal)+"\n") FILE.write(repr(self.d.downTotal)+"\n")
|
FILE.write(repr(self.upTotal)+"\n") FILE.write(repr(self.downTotal)+"\n")
|
def shutdown(): print "shutdown." self.d.display({'activity':_("shutting down"), 'fractionDone':0}) if self.multitorrent: df = self.multitorrent.shutdown() stop_rawserver = lambda *a : rawserver.stop() df.addCallbacks(stop_rawserver, stop_rawserver) else: rawserver.stop()
|
""" return int(n)
|
def fmtsize(n): s = str(n) size = s[-3:] while len(s) > 3: s = s[:-3] size = '%s,%s' % (s[-3:], size) size = '%s (%s)' % (size, str(Size(n))) return size
|
|
self.downRate = '---'
|
self.downRate = '0.0 kB/s'
|
def finished(self): self.done = True # self.downRate = '---' # self.downRate = '0.0 kB/s' self.downRate = '---' self.display({'activity':_("download succeeded"), 'fractionDone':1})
|
if not self.errors: print _("Log: none") else: print _("Log:") for err in self.errors[-4:]: print err print print _("saving: "), self.file print _("file size: "), self.fileSize print _("percent done: "), self.percentDone print _("time left: "), self.timeEst print _("download to: "), self.downloadTo print _("download rate: "), self.downRate print _("upload rate: "), self.upRate print _("share rating: "), self.shareRating print _("seed status: "), self.seedStatus print _("peer status: "), self.peerStatus
|
def display(self, statistics): fractionDone = statistics.get('fractionDone') activity = statistics.get('activity') timeEst = statistics.get('timeEst') downRate = statistics.get('downRate') upRate = statistics.get('upRate') spew = statistics.get('spew')
|
|
FILE.write(repr(self.fileSize))
|
FILE.write(repr(self.fileSize_stat))
|
def display(self, statistics): fractionDone = statistics.get('fractionDone') activity = statistics.get('activity') timeEst = statistics.get('timeEst') downRate = statistics.get('downRate') upRate = statistics.get('upRate') spew = statistics.get('spew')
|
FILE.write(repr(self.d.fileSize))
|
FILE.write(repr(self.d.fileSize_stat))
|
def shutdown(): print "shutdown." self.d.display({'activity':_("shutting down"), 'fractionDone':0}) if self.multitorrent: df = self.multitorrent.shutdown() stop_rawserver = lambda *a : rawserver.stop() df.addCallbacks(stop_rawserver, stop_rawserver) else: rawserver.stop()
|
for x in arange(100)/5. - 10.:
|
for x in Numeric.arange(100)/5. - 10.:
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
x = arange(100)/5. - 10.
|
x = Numeric.arange(100)/5. - 10.
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
x = arange(35)/2.0 y = arange(30)/10.0 - 1.5
|
x = Numeric.arange(35)/2.0 y = Numeric.arange(30)/10.0 - 1.5
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
m = (sin(xm) + 0.1*xm) - ym**2
|
m = (Numeric.sin(xm) + 0.1*xm) - ym**2
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y))
|
g.splot(gp.GridFunc(lambda x,y: math.sin(x) + 0.1*x - y**2, x,y))
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y,
|
g.splot(gp.GridFunc(lambda x,y: Numeric.sin(x) + 0.1*x - y**2, x,y,
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = gp.Gnuplot() g.clear() # Make a temporary file: file1 = gp.TempFile() # will be deleted upon exit f = open(file1.filename, 'w') for x in arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(gp.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(gp.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(gp.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(gp.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = gp.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(gp.File(file1.filename)) wait('Generate a File given a TempFile object') g.plot(gp.File(file1)) wait('Style lines') g.plot(gp.File(file1.filename, with='lines')) wait('using=1, using=(1,)') g.plot(gp.File(file1.filename, using=1, with='lines'), gp.File(file1.filename, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(gp.File(file1.filename, using=(1,2)), gp.File(file1.filename, using='1:3')) wait('title=None') g.plot(gp.File(file1.filename, title=None)) wait('title="title"') g.plot(gp.File(file1.filename, title='title')) print 'Change File attributes after construction:' f = gp.File(file1.filename) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(gp.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(gp.Data(d, inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(gp.Data(d, with='lp 4 4')) wait('cols=0') g.plot(gp.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(gp.Data(d, cols=(0,1), inline=0), gp.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(gp.Data(d, cols=(0,1), inline=1), gp.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(gp.Data(d, title=None)) wait('title="Cosine of x"') g.plot(gp.Data(d, title='Cosine of x')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' g.hardcopy('gp_test.ps', enhanced=1, color=1) print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' g.splot(gp.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(gp.Data(d, with='linesp', inline=1)) print '############### test GridData and GridFunc #######################' # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(gp.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(gp.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(gp.GridData(m,x,y, binary=1)) wait('The same thing using GridFunc to tabulate function') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y)) wait('Use GridFunc in ufunc mode') g.splot(gp.GridFunc(lambda x,y: sin(x) + 0.1*x - y**2, x,y, ufunc=1, binary=1)) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
g = Gnuplot.Gnuplot()
|
g = Gnuplot.Gnuplot(debug=1)
|
def main(): """Exercise the Gnuplot module.""" wait('Popping up a blank gnuplot window on your screen.') g = Gnuplot.Gnuplot() g.clear() # Make a temporary file: filename1 = tempfile.mktemp() f = open(filename1, 'w') for x in Numeric.arange(100)/5. - 10.: f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() # ensure that file will be deleted upon exit: file1 = Gnuplot.PlotItems.TempFile(filename1) print '############### test Func ########################################' wait('Plot a gnuplot-generated function') g.plot(Gnuplot.Func('sin(x)')) wait('Set title and axis labels and try replot()') g.title('Title') g.xlabel('x') g.ylabel('y') g.replot() wait('Style linespoints') g.plot(Gnuplot.Func('sin(x)', with='linespoints')) wait('title=None') g.plot(Gnuplot.Func('sin(x)', title=None)) wait('title="Sine of x"') g.plot(Gnuplot.Func('sin(x)', title='Sine of x')) wait('axes=x2y2') g.plot(Gnuplot.Func('sin(x)', axes='x2y2', title='Sine of x')) print 'Change Func attributes after construction:' f = Gnuplot.Func('sin(x)') wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) wait('title="Sine of x"') f.set_option(title='Sine of x') g.plot(f) wait('axes=x2y2') f.set_option(axes='x2y2') g.plot(f) print '############### test File ########################################' wait('Generate a File from a filename') g.plot(Gnuplot.File(filename1)) wait('Generate a File given a TempFile object') g.plot(Gnuplot.File(file1)) wait('Style lines') g.plot(Gnuplot.File(filename1, with='lines')) wait('using=1, using=(1,)') g.plot(Gnuplot.File(filename1, using=1, with='lines'), Gnuplot.File(filename1, using=(1,), with='points')) wait('using=(1,2), using="1:3"') g.plot(Gnuplot.File(filename1, using=(1,2)), Gnuplot.File(filename1, using='1:3')) wait('title=None') g.plot(Gnuplot.File(filename1, title=None)) wait('title="title"') g.plot(Gnuplot.File(filename1, title='title')) print 'Change File attributes after construction:' f = Gnuplot.File(filename1) wait('Original') g.plot(f) wait('Style linespoints') f.set_option(with='linespoints') g.plot(f) wait('using=(1,3)') f.set_option(using=(1,3)) g.plot(f) wait('title=None') f.set_option(title=None) g.plot(f) print '############### test Data ########################################' x = Numeric.arange(100)/5. - 10. y1 = Numeric.cos(x) y2 = Numeric.sin(x) d = Numeric.transpose((x,y1,y2)) wait('Plot Data, specified column-by-column') g.plot(Gnuplot.Data(x,y2, inline=0)) wait('Same thing, inline data') g.plot(Gnuplot.Data(x,y2, inline=1)) wait('Plot Data, specified by an array') g.plot(Gnuplot.Data(d, inline=0)) wait('Same thing, inline data') g.plot(Gnuplot.Data(d, inline=1)) wait('with="lp 4 4"') g.plot(Gnuplot.Data(d, with='lp 4 4')) wait('cols=0') g.plot(Gnuplot.Data(d, cols=0)) wait('cols=(0,1), cols=(0,2)') g.plot(Gnuplot.Data(d, cols=(0,1), inline=0), Gnuplot.Data(d, cols=(0,2), inline=0)) wait('Same thing, inline data') g.plot(Gnuplot.Data(d, cols=(0,1), inline=1), Gnuplot.Data(d, cols=(0,2), inline=1)) wait('Change title and replot()') g.title('New title') g.replot() wait('title=None') g.plot(Gnuplot.Data(d, title=None)) wait('title="Cosine of x"') g.plot(Gnuplot.Data(d, title='Cosine of x')) print '############### test compute_Data ################################' x = Numeric.arange(100)/5. - 10. wait('Plot Data, computed by Gnuplot.py') g.plot(Gnuplot.funcutils.compute_Data(x, lambda x: math.cos(x), inline=0)) wait('Same thing, inline data') g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, inline=1)) wait('with="lp 4 4"') g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, with='lp 4 4')) print '############### test hardcopy ####################################' print '******** Generating postscript file "gp_test.ps" ********' wait() g.plot(Gnuplot.Func('cos(0.5*x*x)', with='linespoints 2 2', title='cos(0.5*x^2)')) g.hardcopy('gp_test.ps') wait('Testing hardcopy options: mode="landscape"') g.hardcopy('gp_test.ps', mode='landscape') wait('Testing hardcopy options: mode="portrait"') g.hardcopy('gp_test.ps', mode='portrait') wait('Testing hardcopy options: mode="eps"') g.hardcopy('gp_test.ps', mode='eps') wait('Testing hardcopy options: eps=1') g.hardcopy('gp_test.ps', eps=1) wait('Testing hardcopy options: enhanced=1') g.hardcopy('gp_test.ps', eps=0, enhanced=1) wait('Testing hardcopy options: enhanced=0') g.hardcopy('gp_test.ps', enhanced=0) wait('Testing hardcopy options: color=1') g.hardcopy('gp_test.ps', color=1) wait('Testing hardcopy options: solid=1') g.hardcopy('gp_test.ps', color=0, solid=1) wait('Testing hardcopy options: duplexing="duplex"') g.hardcopy('gp_test.ps', solid=0, duplexing='duplex') wait('Testing hardcopy options: duplexing="defaultplex"') g.hardcopy('gp_test.ps', duplexing='defaultplex') wait('Testing hardcopy options: fontname="Times-Italic"') g.hardcopy('gp_test.ps', fontname='Times-Italic') wait('Testing hardcopy options: fontsize=20') g.hardcopy('gp_test.ps', fontsize=20) wait('Testing hardcopy options: mode="default"') g.hardcopy('gp_test.ps', mode='default') print '############### test shortcuts ###################################' wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) print '############### test splot #######################################' wait('a 3-d curve') g.splot(Gnuplot.Data(d, with='linesp', inline=0)) wait('Same thing, inline data') g.splot(Gnuplot.Data(d, with='linesp', inline=1)) print '############### test GridData and compute_GridData ###############' # set up x and y values at which the function will be tabulated: x = Numeric.arange(35)/2.0 y = Numeric.arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (Numeric.sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.xlabel('x') g.ylabel('y') g.splot(Gnuplot.GridData(m,x,y, binary=0, inline=0)) wait('Same thing, inline data') g.splot(Gnuplot.GridData(m,x,y, binary=0, inline=1)) wait('The same thing using binary mode') g.splot(Gnuplot.GridData(m,x,y, binary=1)) wait('The same thing using compute_GridData to tabulate function') g.splot(Gnuplot.funcutils.compute_GridData( x,y, lambda x,y: math.sin(x) + 0.1*x - y**2, )) wait('Use compute_GridData in ufunc and binary mode') g.splot(Gnuplot.funcutils.compute_GridData( x,y, lambda x,y: Numeric.sin(x) + 0.1*x - y**2, ufunc=1, binary=1, )) wait('And now rotate it a bit') for view in range(35,70,5): g('set view 60, %d' % view) g.replot() time.sleep(1.0) wait(prompt='Press return to end the test.\n')
|
class file(plotitem): """a plotitem representing a file that contains gnuplot data.""" _option_list = plotitem._option_list.copy()
|
class File(PlotItem): """A PlotItem representing a file that contains gnuplot data.""" _option_list = PlotItem._option_list.copy()
|
def __del__(self): """Delete the referenced file."""
|
'smooth', smooth, none, 'smooth %s'),
|
'smooth', smooth, None, 'smooth %s'),
|
def __del__(self): """Delete the referenced file."""
|
"""construct a file object.
|
"""Construct a File object.
|
def __init__(self, file, **keyw): """construct a file object.
|
class OptionException(Exception): pass
|
class OptionException(Exception): pass class DataException(Exception): pass
|
def test_persist(): global _recognizes_persist if _recognizes_persist is None: g = os.popen('echo | gnuplot -persist 2>&1', 'r') response = g.readlines() g.close() _recognizes_persist = ((not response) or (string.find(response[0], '-persist') == -1)) return _recognizes_persist
|
if item.shape[1] == 1: newitems.append(Data(item, with='lines'))
|
dim = len(item.shape) if dim == 1: newitems.append(Data(item[:, Numeric.NewAxis], with='lines')) elif dim == 2: if item.shape[1] == 1: newitems.append(Data(item, with='lines')) else: tempf = TempArrayFile(item) for col in range(1, item.shape[1]): newitems.append(File(tempf, using=(1,col+1), with='lines'))
|
def plot(*items, **kw): """plot data using gnuplot. This command is roughly compatible with old Gnuplot plot command. It is provided for backwards compatibility only. It is recommended that you use the new object-oriented Gnuplot interface, which is much more flexible. It can only plot Numeric array data. In this routine an NxM array is plotted as M-1 separate datasets, using columns 1:2, 1:3, ..., 1:M. Limitations: - If persist is not available, the temporary files are not deleted until final python cleanup.""" newitems = [] for item in items: # assume data is an array: item = Numeric.asarray(item, Numeric.Float) if item.shape[1] == 1: # one column; just store one item for tempfile: newitems.append(Data(item, with='lines')) else: # more than one column; store item for each 1:2, 1:3, etc. tempf = TempArrayFile(item) for col in range(1, item.shape[1]): newitems.append(File(tempf, using=(1,col+1), with='lines')) items = tuple(newitems) del newitems if kw.has_key('file'): g = Gnuplot() # setup plot without actually plotting (so data don't appear # on the screen): g._add_to_queue(items) g.hardcopy(kw['file']) # process will be closed automatically elif test_persist(): g = Gnuplot(persist=1) apply(g.plot, items) # process will be closed automatically else: g = Gnuplot() apply(g.plot, items) # prevent process from being deleted: _gnuplot_processes.append(g)
|
tempf = TempArrayFile(item) for col in range(1, item.shape[1]): newitems.append(File(tempf, using=(1,col+1), with='lines'))
|
raise DataException("Data array must be 1 or 2 dimensional")
|
def plot(*items, **kw): """plot data using gnuplot. This command is roughly compatible with old Gnuplot plot command. It is provided for backwards compatibility only. It is recommended that you use the new object-oriented Gnuplot interface, which is much more flexible. It can only plot Numeric array data. In this routine an NxM array is plotted as M-1 separate datasets, using columns 1:2, 1:3, ..., 1:M. Limitations: - If persist is not available, the temporary files are not deleted until final python cleanup.""" newitems = [] for item in items: # assume data is an array: item = Numeric.asarray(item, Numeric.Float) if item.shape[1] == 1: # one column; just store one item for tempfile: newitems.append(Data(item, with='lines')) else: # more than one column; store item for each 1:2, 1:3, etc. tempf = TempArrayFile(item) for col in range(1, item.shape[1]): newitems.append(File(tempf, using=(1,col+1), with='lines')) items = tuple(newitems) del newitems if kw.has_key('file'): g = Gnuplot() # setup plot without actually plotting (so data don't appear # on the screen): g._add_to_queue(items) g.hardcopy(kw['file']) # process will be closed automatically elif test_persist(): g = Gnuplot(persist=1) apply(g.plot, items) # process will be closed automatically else: g = Gnuplot() apply(g.plot, items) # prevent process from being deleted: _gnuplot_processes.append(g)
|
print "\n Generating postscript file 'junk.ps'\n" g2.hardcopy('junk.ps', color=1)
|
print "\n Generating postscript file 'gnuplot_test1.ps'\n" g2.hardcopy('gnuplot_test1.ps', color=1)
|
def plot(*items, **kw): """plot data using gnuplot. This command is roughly compatible with old Gnuplot plot command. It is provided for backwards compatibility only. It is recommended that you use the new object-oriented Gnuplot interface, which is much more flexible. It can only plot Numeric array data. In this routine an NxM array is plotted as M-1 separate datasets, using columns 1:2, 1:3, ..., 1:M. Limitations: - If persist is not available, the temporary files are not deleted until final python cleanup.""" newitems = [] for item in items: # assume data is an array: item = Numeric.asarray(item, Numeric.Float) if item.shape[1] == 1: # one column; just store one item for tempfile: newitems.append(Data(item, with='lines')) else: # more than one column; store item for each 1:2, 1:3, etc. tempf = TempArrayFile(item) for col in range(1, item.shape[1]): newitems.append(File(tempf, using=(1,col+1), with='lines')) items = tuple(newitems) del newitems if kw.has_key('file'): g = Gnuplot() # setup plot without actually plotting (so data don't appear # on the screen): g._add_to_queue(items) g.hardcopy(kw['file']) # process will be closed automatically elif test_persist(): g = Gnuplot(persist=1) apply(g.plot, items) # process will be closed automatically else: g = Gnuplot() apply(g.plot, items) # prevent process from being deleted: _gnuplot_processes.append(g)
|
print setterm
|
def hardcopy(self, filename=None, terminal='postscript', **keyw): """Create a hardcopy of the current plot.
|
|
def set_option(self, with=_unset, title=_unset, **keyw):
|
def set_option(self, with=_unset, smooth=_unset, title=_unset, **keyw):
|
def set_option(self, with=_unset, title=_unset, **keyw): """Set or change a plot option for this PlotItem.
|
_option_sequence = ['binary', 'using', 'title', 'with']
|
_option_sequence = ['binary', 'using', 'smooth', 'title', 'with']
|
def clear_option(self, name): """Clear (unset) a plot option. No error if option was not set."""
|
set = Numeric.asarray(set, Numeric.Float)
|
set = Numeric.asarray(set[0], Numeric.Float)
|
def __init__(self, *set, **keyw): """Construct a Data object from a numeric array.
|
def grid_function(f, xvals, yvals, typecode=Numeric.Float32):
|
def grid_function(f, xvals, yvals, typecode=None, ufunc=0):
|
def grid_function(f, xvals, yvals, typecode=Numeric.Float32): """Evaluate and tabulate a function on a grid. 'xvals' and 'yvals' should be 1-D arrays listing the values of x and y at which 'f' should be tabulated. 'f' should be a function taking two floating point arguments. The return value is a matrix M where 'M[i,j] = f(xvals[i],yvals[j])', which can for example be used in the 'GridData' constructor. Note that 'f' is evaluated at each pair of points using a Python loop, which can be slow if the number of points is large. If speed is an issue, you should if possible compute functions matrix-wise using Numeric's built-in ufuncs. """ m = Numeric.zeros((len(xvals), len(yvals)), typecode) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
Note that 'f' is evaluated at each pair of points using a Python loop, which can be slow if the number of points is large. If speed is an issue, you should if possible compute functions matrix-wise using Numeric's built-in ufuncs.
|
If 'ufunc=0', then 'f' is evaluated at each pair of points using a Python loop. This can be slow if the number of points is large. If speed is an issue, you should write 'f' in terms of Numeric ufuncs and use the 'ufunc=1' feature described next. If called with 'ufunc=1', then 'f' should be a function that is composed entirely of ufuncs (i.e., a function that can operate element-by-element on whole matrices). It will be passed the xvals and yvals as rectangular matrices.
|
def grid_function(f, xvals, yvals, typecode=Numeric.Float32): """Evaluate and tabulate a function on a grid. 'xvals' and 'yvals' should be 1-D arrays listing the values of x and y at which 'f' should be tabulated. 'f' should be a function taking two floating point arguments. The return value is a matrix M where 'M[i,j] = f(xvals[i],yvals[j])', which can for example be used in the 'GridData' constructor. Note that 'f' is evaluated at each pair of points using a Python loop, which can be slow if the number of points is large. If speed is an issue, you should if possible compute functions matrix-wise using Numeric's built-in ufuncs. """ m = Numeric.zeros((len(xvals), len(yvals)), typecode) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
m = Numeric.zeros((len(xvals), len(yvals)), typecode) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
xvals = Numeric.asarray(xvals, typecode) yvals = Numeric.asarray(yvals, typecode) if ufunc: return f(xvals[:,Numeric.NewAxis], yvals[Numeric.NewAxis,:]) else: m = Numeric.zeros((len(xvals), len(yvals)), xvals.typecode()) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
def grid_function(f, xvals, yvals, typecode=Numeric.Float32): """Evaluate and tabulate a function on a grid. 'xvals' and 'yvals' should be 1-D arrays listing the values of x and y at which 'f' should be tabulated. 'f' should be a function taking two floating point arguments. The return value is a matrix M where 'M[i,j] = f(xvals[i],yvals[j])', which can for example be used in the 'GridData' constructor. Note that 'f' is evaluated at each pair of points using a Python loop, which can be slow if the number of points is large. If speed is an issue, you should if possible compute functions matrix-wise using Numeric's built-in ufuncs. """ m = Numeric.zeros((len(xvals), len(yvals)), typecode) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
If 'binary=1' is passed to the constructor, the data will be passed to gnuplot in binary format and the 'binary' option added to the splot command line. Binary format is faster and usually saves disk space but is not human-readable. If your version of gnuplot doesn't support binary format (it is a recently-added feature), it can be disabled by setting the configuration variable '_recognizes_binary_splot=0' at the top of this file.
|
def pipein(self, f): if self._data: f.write(self._data)
|
|
def __init__(self, toplot, xvals=None, yvals=None,
|
def __init__(self, data, xvals=None, yvals=None,
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
'toplot' -- the thing to plot: a 2-d array with dimensions (numx,numy), OR a callable object for which toplot(x,y) returns a number.
|
'data' -- the data to plot: a 2-d array with dimensions (numx,numy).
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
'toplot' can be a data array, in which case it should hold the values of a function f(x,y) tabulated on a grid of points, such that 'toplot[i,j] == f(xvals[i], yvals[j])'. If 'xvals' and/or 'yvals' are omitted, integers (starting with 0) are used for that coordinate. The data are written to a temporary file; no copy of the data is kept in memory. Alternatively 'toplot' can be a function object taking two arguments (and 'xvals' and 'yvals' must be specified explicitly). In this case 'toplot(x,y)' will be computed at all grid points obtained by combining elements from 'xvals' and 'yvals'.
|
'data' must be a data array holding the values of a function f(x,y) tabulated on a grid of points, such that 'data[i,j] == f(xvals[i], yvals[j])'. If 'xvals' and/or 'yvals' are omitted, integers (starting with 0) are used for that coordinate. The data are written to a temporary file; no copy of the data is kept in memory.
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
f(x,y)' triplets that can be used by gnuplot's 'splot' command. If 'binary=1' then the data are written to a file in a binary format that 'splot' can understand.
|
f(x,y)' triplets (y changes most rapidly) that can be used by gnuplot's 'splot' command. Blank lines are included each time the value of x changes so that gnuplot knows to plot a surface through the data. If 'binary=1' then the data are written to a file in a binary format that 'splot' can understand. Binary format is faster and usually saves disk space but is not human-readable. If your version of gnuplot doesn't support binary format (it is a recently-added feature), this behavior can be disabled by setting the configuration variable '_recognizes_binary_splot=0' at the top of this file.
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
try: data = float_array(toplot) except TypeError:
|
data = float_array(data) assert len(data.shape) == 2 (numx, numy) = data.shape if xvals is None: xvals = Numeric.arange(numx) else:
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
(numx,) = xvals.shape
|
assert xvals.shape == (numx,) if yvals is None: yvals = Numeric.arange(numy) else:
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
(numy,) = yvals.shape try: data = toplot(xvals,yvals) except: data = grid_function(toplot, xvals, yvals) else: assert len(data.shape) == 2 (numx, numy) = data.shape if xvals is None: xvals = Numeric.arange(numx) else: xvals = float_array(xvals) assert xvals.shape == (numx,) if yvals is None: yvals = Numeric.arange(numy) else: yvals = float_array(yvals) assert yvals.shape == (numy,)
|
assert yvals.shape == (numy,)
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
inline = not binary and _prefer_inline_data
|
inline = (not binary) and _prefer_inline_data
|
def __init__(self, toplot, xvals=None, yvals=None, binary=1, inline=_unset, **keyw): """GridData constructor.
|
raw_input('Please press return to continue...\n') def f(x,y): import math print x,y return math.exp(- 0.01 * (x**2 + y**2)) g.splot(GridFunc(f, x,y, binary=0))
|
def demo(): """Demonstrate the package.""" from Numeric import * # A straightforward use of gnuplot. The `debug=1' switch is used # in these examples so that the commands that are sent to gnuplot # are also output on stderr. g = Gnuplot(debug=1) g.title('A simple example') # (optional) g('set data style linespoints') # give gnuplot an arbitrary command # Plot a list of (x, y) pairs (tuples or a Numeric array would # also be OK): g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) raw_input('Please press return to continue...\n') g.reset() # Plot one dataset from an array and one via a gnuplot function; # also demonstrate the use of item-specific options: x = arange(10, typecode=Float) y1 = x**2 # Notice how this plotitem is created here but used later? This # is convenient if the same dataset has to be plotted multiple # times. It is also more efficient because the data need only be # written to a temporary file once. d = Data(x, y1, title='calculated by python', with='points 3 3') g.title('Data can be computed by python or gnuplot') g.xlabel('x') g.ylabel('x squared') # Plot a function alongside the Data PlotItem defined above: g.plot(Func('x**2', title='calculated by gnuplot'), d) raw_input('Please press return to continue...\n') # Save what we just plotted as a color postscript file. # With the enhanced postscript option, it is possible to show `x # squared' with a superscript (plus much, much more; see `help set # term postscript' in the gnuplot docs). If your gnuplot doesn't # support enhanced mode, set `enhanced=0' below. g.ylabel('x^2') # take advantage of enhanced postscript mode g.hardcopy('gp_test.ps', enhanced=1, color=1) print ('\n******** Saved plot to postscript file "gp_test.ps" ********\n') raw_input('Please press return to continue...\n') g.reset() # Demonstrate a 3-d plot: # set up x and y values at which the function will be tabulated: x = arange(35)/2.0 y = arange(30)/10.0 - 1.5 # Make a 2-d array containing a function of x and y. First create # xm and ym which contain the x and y values in a matrix form that # can be `broadcast' into a matrix of the appropriate shape: xm = x[:,NewAxis] ym = y[NewAxis,:] m = (sin(xm) + 0.1*xm) - ym**2 g('set parametric') g('set data style lines') g('set hidden') g('set contour base') g.title('An example of a surface plot') g.xlabel('x') g.ylabel('y') # The `binary=1' option would cause communication with gnuplot to # be in binary format, which is considerably faster and uses less # disk space. (This only works with the splot command due to # limitations of gnuplot.) `binary=1' is the default, but here we # disable binary because older versions of gnuplot don't allow # binary data. Change this to `binary=1' (or omit the binary # option) to get the advantage of binary format. g.splot(GridData(m,x,y, binary=0)) # Delay so the user can see the plots: raw_input('Please press return to continue...\n') # Explicit delete shouldn't be necessary, but if you are having # trouble with temporary files being left behind, uncomment the # following: #del g, d
|
|
m = Numeric.zeros((len(xvals), len(yvals)), xvals.typecode())
|
if typecode is None: typecode = (Numeric.zeros((1,), xvals.typecode()) + Numeric.zeros((1,), yvals.typecode())).typecode() m = Numeric.zeros((len(xvals), len(yvals)), typecode)
|
def grid_function(f, xvals, yvals, typecode=None, ufunc=0): """Evaluate and tabulate a function on a grid. 'xvals' and 'yvals' should be 1-D arrays listing the values of x and y at which 'f' should be tabulated. 'f' should be a function taking two floating point arguments. The return value is a matrix M where 'M[i,j] = f(xvals[i],yvals[j])', which can for example be used in the 'GridData' constructor. If 'ufunc=0', then 'f' is evaluated at each pair of points using a Python loop. This can be slow if the number of points is large. If speed is an issue, you should write 'f' in terms of Numeric ufuncs and use the 'ufunc=1' feature described next. If called with 'ufunc=1', then 'f' should be a function that is composed entirely of ufuncs (i.e., a function that can operate element-by-element on whole matrices). It will be passed the xvals and yvals as rectangular matrices. """ xvals = Numeric.asarray(xvals, typecode) yvals = Numeric.asarray(yvals, typecode) if ufunc: return f(xvals[:,Numeric.NewAxis], yvals[Numeric.NewAxis,:]) else: ### The typecode used here isn't really right. m = Numeric.zeros((len(xvals), len(yvals)), xvals.typecode()) for xi in range(len(xvals)): x = xvals[xi] for yi in range(len(yvals)): y = yvals[yi] m[xi,yi] = f(x,y) return m
|
super( D20Damage, self ).__init__( 'Damage', 0, self.range.roll )
|
super( D20Damage, self ).__init__( 'Damage', 0, self.__int__ )
|
def __init__( self, types, size=0, roll="1d8", range=None ): self.range = range or D20DamageRange( size, roll ) self.types = types super( D20Damage, self ).__init__( 'Damage', 0, self.range.roll ) self.mod.static = True
|
bob = D20Character( "Bob", race, { 'STR': 13, 'DEX':15, 'CON':12, 'INT':10, 'WIS':8, 'CHA':18, 'HEIGHT':72, 'WEIGHT':221, 'WIDTH':24, 'DEPTH':12 } )
|
bob = D20Character( "Bob", race, { 'STR': 150, 'DEX':15, 'CON':12, 'INT':10, 'WIS':8, 'CHA':18, 'HEIGHT':72, 'WEIGHT':221, 'WIDTH':24, 'DEPTH':12 } )
|
def getLevel( self ): charlevelnum = 1 try: for level in self.levels[ 'RACE' ].values( ): if level.enabled: charlevelnum += 1 except KeyError: pass return charlevelnum
|
dmg = att.resolve( 18 )
|
dmg = att.resolve( 19, 1 ) """
|
def getLevel( self ): charlevelnum = 1 try: for level in self.levels[ 'RACE' ].values( ): if level.enabled: charlevelnum += 1 except KeyError: pass return charlevelnum
|
self.canvas.set_size_request(self.bg.get_width(), self.bg.get_height())
|
def __init__(self, deferred, netclient, fps): self.fps = fps self.deferred = deferred self.netclient = netclient
|
|
self.canvas.root().add("GnomeCanvasPixbuf", pixbuf=self.bg, )
|
self.tiles = []
|
def __init__(self, deferred, netclient, fps): self.fps = fps self.deferred = deferred self.netclient = netclient
|
self.canvas.connect('size-allocate', self.on_canvas_expose_event)
|
def __init__(self, deferred, netclient, fps): self.fps = fps self.deferred = deferred self.netclient = netclient
|
|
def paintDefault(self):
|
def on_canvas_expose_event(self, w, ev):
|
def paintDefault(self): """Draw the default background""" tile_w = self.bg.get_width() tile_h = self.bg.get_height() # tile the texture root = self.canvas.root() if self.model is None: # root.add("GnomeCanvasPixbuf", x=0, y=0, # pixbuf=self.bg) #root.add("GnomeCanvasPixbuf", x=-129, y=0, # pixbuf=self.bg) root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return # FIXME for x in range(num_x): for y in range(num_y): root.add("GnomeCanvasPixbuf", x=x*tile_w, y=y*tile_h, pixbuf=self.bg) else: FIXME # self.main.blit(self.model.background, (0,0)) # for icon in self.model.icons: # self.main.blit(icon.image, icon.xy)
|
tile_w = self.bg.get_width() tile_h = self.bg.get_height()
|
def paintDefault(self): """Draw the default background""" tile_w = self.bg.get_width() tile_h = self.bg.get_height() # tile the texture root = self.canvas.root() if self.model is None: # root.add("GnomeCanvasPixbuf", x=0, y=0, # pixbuf=self.bg) #root.add("GnomeCanvasPixbuf", x=-129, y=0, # pixbuf=self.bg) root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return # FIXME for x in range(num_x): for y in range(num_y): root.add("GnomeCanvasPixbuf", x=x*tile_w, y=y*tile_h, pixbuf=self.bg) else: FIXME # self.main.blit(self.model.background, (0,0)) # for icon in self.model.icons: # self.main.blit(icon.image, icon.xy)
|
|
root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return
|
tile_w = self.bg.get_width() tile_h = self.bg.get_height() view_w = self.gw_scrolledwindow1.get_hadjustment().page_size view_h = self.gw_scrolledwindow1.get_vadjustment().page_size num_x = (view_w / tile_w) + 1 num_y = (view_h / tile_h) + 1 [w.destroy() for w in self.tiles] self.tiles = []
|
def paintDefault(self): """Draw the default background""" tile_w = self.bg.get_width() tile_h = self.bg.get_height() # tile the texture root = self.canvas.root() if self.model is None: # root.add("GnomeCanvasPixbuf", x=0, y=0, # pixbuf=self.bg) #root.add("GnomeCanvasPixbuf", x=-129, y=0, # pixbuf=self.bg) root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return # FIXME for x in range(num_x): for y in range(num_y): root.add("GnomeCanvasPixbuf", x=x*tile_w, y=y*tile_h, pixbuf=self.bg) else: FIXME # self.main.blit(self.model.background, (0,0)) # for icon in self.model.icons: # self.main.blit(icon.image, icon.xy)
|
root.add("GnomeCanvasPixbuf",
|
w = root.add("GnomeCanvasPixbuf",
|
def paintDefault(self): """Draw the default background""" tile_w = self.bg.get_width() tile_h = self.bg.get_height() # tile the texture root = self.canvas.root() if self.model is None: # root.add("GnomeCanvasPixbuf", x=0, y=0, # pixbuf=self.bg) #root.add("GnomeCanvasPixbuf", x=-129, y=0, # pixbuf=self.bg) root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return # FIXME for x in range(num_x): for y in range(num_y): root.add("GnomeCanvasPixbuf", x=x*tile_w, y=y*tile_h, pixbuf=self.bg) else: FIXME # self.main.blit(self.model.background, (0,0)) # for icon in self.model.icons: # self.main.blit(icon.image, icon.xy)
|
FIXME
|
if self.tiles: [w.destroy() for w in self.tiles] self.tiles = []
|
def paintDefault(self): """Draw the default background""" tile_w = self.bg.get_width() tile_h = self.bg.get_height() # tile the texture root = self.canvas.root() if self.model is None: # root.add("GnomeCanvasPixbuf", x=0, y=0, # pixbuf=self.bg) #root.add("GnomeCanvasPixbuf", x=-129, y=0, # pixbuf=self.bg) root.add("GnomeCanvasRect", x1=0, x2=384, y1=0, y2=384, fill_color="blue", outline_color="black") root.add("GnomeCanvasText", x=0, y=0, text="0,0") root.add("GnomeCanvasText", x=300, y=300, text="300,300") root.add("GnomeCanvasText", x=0, y=300, text="0,300") root.add("GnomeCanvasText", x=300, y=0, text="300,0") return # FIXME for x in range(num_x): for y in range(num_y): root.add("GnomeCanvasPixbuf", x=x*tile_w, y=y*tile_h, pixbuf=self.bg) else: FIXME # self.main.blit(self.model.background, (0,0)) # for icon in self.model.icons: # self.main.blit(icon.image, icon.xy)
|
self.model = Model(pygame.image.load(fs.downloads(mapinfo['name']))) self.main.blit(self.model.background, (0,0))
|
background = gdk.pixbuf_new_from_file(fs.downloads(mapinfo['name'])) self.model = Model(background) root = self.canvas.root() root.add("GnomeCanvasPixbuf", pixbuf=background) self.canvas.set_size_request(background.get_width(), background.get_height() )
|
def displayModel(self): mapinfo = self._getMapInfo() log.msg('displaying map %s' % (mapinfo['name'],)) self.model = Model(pygame.image.load(fs.downloads(mapinfo['name']))) self.main.blit(self.model.background, (0,0)) for n, character in enumerate(self._getCharacterInfo()): icon_image = pygame.image.load(fs.downloads(character['name'])) icon = Icon() self.model.icons.append(icon) icon.image = icon_image icon.xy = n*80, n*80 self.main.blit(icon.image, icon.xy) # self.addCharacter # self.addItem # self.addText # self.addSound # self.clearObscurement() # self.obscure?
|
icon_image = pygame.image.load(fs.downloads(character['name']))
|
icon_image = gdk.pixbuf_new_from_file( fs.downloads(character['name']) )
|
def displayModel(self): mapinfo = self._getMapInfo() log.msg('displaying map %s' % (mapinfo['name'],)) self.model = Model(pygame.image.load(fs.downloads(mapinfo['name']))) self.main.blit(self.model.background, (0,0)) for n, character in enumerate(self._getCharacterInfo()): icon_image = pygame.image.load(fs.downloads(character['name'])) icon = Icon() self.model.icons.append(icon) icon.image = icon_image icon.xy = n*80, n*80 self.main.blit(icon.image, icon.xy) # self.addCharacter # self.addItem # self.addText # self.addSound # self.clearObscurement() # self.obscure?
|
self.main.blit(icon.image, icon.xy)
|
self.canvas.root().add("GnomeCanvasPixbuf", pixbuf=icon.image, x=icon.xy[0], y=icon.xy[1], )
|
def displayModel(self): mapinfo = self._getMapInfo() log.msg('displaying map %s' % (mapinfo['name'],)) self.model = Model(pygame.image.load(fs.downloads(mapinfo['name']))) self.main.blit(self.model.background, (0,0)) for n, character in enumerate(self._getCharacterInfo()): icon_image = pygame.image.load(fs.downloads(character['name'])) icon = Icon() self.model.icons.append(icon) icon.image = icon_image icon.xy = n*80, n*80 self.main.blit(icon.image, icon.xy) # self.addCharacter # self.addItem # self.addText # self.addSound # self.clearObscurement() # self.obscure?
|
args=args[len(groups[0])-1:].lstrip() groups=groups[0].split(',') groups=[conv.group.account.getGroup(group.lstrip('
|
args = args[len(groups[0])-1:].lstrip() acct = conv.group.account groups = groups[0].split(',') groups = [acct.getGroup(group.lstrip('
|
def irccmd_join(self, args, conv): groups=args.split()
|
tabs = IChatConversations(widget) self.webPrint = lambda m: tabs.printClean(m, self.person.name)
|
def __init__(self, widget, *a, **kw): components.Componentized.__init__(self) basechat.Conversation.__init__(self, *a, **kw) self.widget = widget tabs = IChatConversations(widget) self.webPrint = lambda m: tabs.printClean(m, self.person.name)
|
|
return self.webPrint(t)
|
return ITextArea(self).printClean(t)
|
def showMessage(self, text, metadata=None): if metadata and metadata.get("style", None) == "emote": t = '* %s %s' % (self.person.name, text) else: t = "<%s> %s" % (self.person.name, text) return self.webPrint(t)
|
return self.webPrint(event)
|
return ITextArea(self).printClean(event)
|
def contactChangedNick(self, person, newnick): basechat.Conversation.contactChangedNick(self, person, newnick) event = "-!- %s is now known as %s" % (person.name, newnick) return self.webPrint(event)
|
self.webPrint(out)
|
ITextArea(self).printClean(out)
|
def sendText(self, text, metadata=None): r = self.person.sendMessage(text, metadata) me = self.person.account.client.name if metadata and metadata.get('style', None) == 'emote': out = u'* %s %s' % (me, text) else: out = u'<%s> %s' % (me, text) self.webPrint(out)
|
scale100px = A.point4decimal("Distance in meters of 100 map px @ 100% zoom")
|
scale100px = A.point4decimal()
|
def installOn(self, other): other.powerUp(self, IArticle)
|
('MFen', 'VellumTalk', 'MFen', '{100x2}', r'MFen, you rolled: 100x2 = {100, 100} \(sorted\)'),
|
def clientConnectionFailed(self, connector, reason): print "connection failed:", reason reactor.stop()
|
|
acct = VellumIRCAccount("IRC", 1, username, password, host,
|
acct = ircsupport.IRCAccount("IRC", 1, username, password, host,
|
def doConnection(self, host, username, password, channels): if username in ACCOUNTS and ACCOUNTS[username].isOnline(): self.disconnect(ACCOUNTS[username])
|
self.webPrint = lambda m: widget.printClean(self.group.name, m)
|
self.webPrint = lambda m: widget.printClean('
|
def __init__(self, widget, *a, **kw): basechat.GroupConversation.__init__(self, *a, **kw) self.widget = widget self.webPrint = lambda m: widget.printClean(self.group.name, m)
|
if self.group.name in self.widget.conversations:
|
groupname = ' if groupname in self.widget.conversations:
|
def show(self): """If you don't have a GUI, this is a no-op. """ if self.group.name in self.widget.conversations: self.widget.foregroundConversation = self self.widget.callRemote("show", unicode(self.group.name))
|
self.widget.callRemote("show", unicode(self.group.name))
|
self.widget.callRemote("show", unicode(groupname))
|
def show(self): """If you don't have a GUI, this is a no-op. """ if self.group.name in self.widget.conversations: self.widget.foregroundConversation = self self.widget.callRemote("show", unicode(self.group.name))
|
class Zoom(Operation):
|
class Magnify(Operation):
|
def update(self, x, y): ha = self.gui.canvas.get_hadjustment() va = self.gui.canvas.get_vadjustment()
|
_d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
x1 = self.drawn.get_property('x1') y1 = self.drawn.get_property('y1') x2 = self.drawn.get_property('x2') y2 = self.drawn.get_property('y2')
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
current_w = alloc.width current_h = alloc.height box_w = abs(_d['x2'] - _d['x1']) box_h = abs(_d['y2'] - _d['y1']) ratio_w = current_w / box_w ratio_h = current_h / box_h
|
box_w = abs(x2 - x1) box_h = abs(y2 - y1) ratio_w = alloc.width / box_w ratio_h = alloc.height / box_h
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
current_zoom = 10.0 / canvas.c2w(10, 10)[0]
|
last_zoom = 10.0 / canvas.c2w(10, 10)[0]
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
zoom = current_zoom
|
zoom = last_zoom
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
if _d['x1'] < _d['x2']: west = _d['x1'] else: west = _d['x2'] if _d['y1'] < _d['y2']: north = _d['y1'] else: north = _d['y2'] hadj, vadj = canvas.w2c(west, north)
|
if x1 < x2: west = x1 if y1 < y2: north = y1
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
x_offset = hadj y_offset = vadj + box_h/2 - (alloc.height/2 * zoom)
|
x_offset = west y_offset = north - (alloc.height - box_h) / 2
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
y_offset = vadj x_offset = hadj + box_w/2 - (alloc.width/2 * zoom)
|
x_offset = west - (alloc.width - box_w) / 2 y_offset = north
|
def finish(self): """Zoom so the inscribed area is maximized in the main window""" if self.drawn: _d = {} for point in ('x1', 'y1', 'x2', 'y2'): _d[point] = self.drawn.get_property(point)
|
'zoom_on': Zoom,
|
'magnify_on': Magnify,
|
def __init__(self, deferred, netclient, fps): self.fps = fps self.deferred = deferred self.netclient = netclient
|
'Tabby': _f('tab.js'), 'Tabby.Tests': _f('livetest_tab.js')
|
'Tabby': _f('tabs.js'), 'Tabby.Tests': _f('livetest_tabs.js'),
|
def _f(*sib): return util.sibpath(webby.__file__, '/'.join(sib))
|
log.msg('|||'.join(prefix, command, params))
|
log.msg('|||'.join((prefix, command, params)))
|
def irc_unknown(self, prefix, command, params): log.msg('|||'.join(prefix, command, params))
|
acct = proto.WebbyAccount('%s@%s' % key,
|
acct = WebbyAccount('%s@%s' % key,
|
def doConnection(self, host, username, password, channels): key = (username, host) if key in ACCOUNTS and ACCOUNTS[key].isOnline(): self.disconnect(ACCOUNTS[key])
|
def render_debug(self, ctx, data): f = athena.IntrospectionFragment() f.setFragmentParent(self) return ctx.tag[f]
|
def render_debug(self, ctx, data): f = athena.IntrospectionFragment() f.setFragmentParent(self) return ctx.tag[f]
|
|
print "3 !!!!!!!!!!!!!!!!!!!!!!! abstract connectionLost", self
|
def connectionLost(self, reason): """ Basically, t.words.im.basesupport.AbstractClientMixin is completely *fucked* in the head. Subclassing it is impossible, because of the stupid fucking self._protoBase, which turns out to be IRCProto, not this class.
|
|
self.__dict__['observers'] = []
|
self.observers = []
|
def __init__(self): self.__dict__['observers'] = []
|
def __setattr__(self, name, value): raise RuntimeError("Assignments must be made through an Arbiter.")
|
def __setattr__(self, name, value): raise RuntimeError("Assignments must be made through an Arbiter.")
|
|
old = getattr(n, name, None)
|
def __setattr__(self, name, value): n = self.noumenon old = getattr(n, name, None)
|
|
if name in self.noumenon.__phenomena__: return getattr(self.noumenon, name) raise AttributeError(name)
|
return getattr(self.noumenon, name)
|
def __getattr__(self, name): if name in self.noumenon.__phenomena__: return getattr(self.noumenon, name) raise AttributeError(name)
|
h = Hork()
|
h = Hork().getArbiter('ROOT')
|
def bar_changed(self, tag, model, old, new): output.append(('bar', old, new, tag))
|
try: h.foo = 1 except RuntimeError, e: pass else: assert 0, "should not be able to assign to h.foo"
|
def bar_changed(self, tag, model, old, new): output.append(('bar', old, new, tag))
|
|
print 'TODO: fit'
|
alloc = self.canvas.get_allocation() _, _, canv_w, canv_h = self.canvas.get_scroll_region() ratio_w = alloc.width / canv_w ratio_h = alloc.height / canv_h self.canvas.set_pixels_per_unit(min([ratio_w, ratio_h]))
|
def on_zoomfit_activate(self, widget): if self.canvas: print 'TODO: fit'
|
log.msg('|||'.join((prefix, command, params)))
|
log.msg('|||'.join((prefix, command, repr(params))))
|
def irc_unknown(self, prefix, command, params): log.msg('|||'.join((prefix, command, params)))
|
dispatcher.connect(self.receivePropertyChange, self) def receivePropertyChange(self, property, value): setattr(self, property, value)
|
self.receiver = lambda property,value:setattr(self, property, value) dispatcher.connect(self.receiver, self)
|
def __init__(self): dispatcher.connect(self.receivePropertyChange, self)
|
assert None, "begin must be implemented in a subclass"
|
pass
|
def begin(self): assert None, "begin must be implemented in a subclass"
|
finish = begin class Drag(Operation): def begin(self): pass
|
def endAt(self, x, y): self.end_x = x self.end_y = y self.finish()
|
|
pass
|
cursor = gdk.Cursor(gdk.TARGET) def beginState(self): self.gui.canvas.window.set_cursor(self.cursor) def endState(self): self.gui.canvas.window.set_cursor(None)
|
def update(self, x, y): viewport = self.gui.gw_viewport1 ha = viewport.get_hadjustment() va = viewport.get_vadjustment()
|
'drag_on': Drag,
|
'pan_on': Pan,
|
def __init__(self, deferred, netclient, fps): self.fps = fps self.deferred = deferred self.netclient = netclient
|
self.tool_active = widget.name
|
tool_changed = (self.tool_active != widget.name) if self.active_operation and tool_changed: self.active_operation.endState()
|
def on_toolbar_toggled(self, widget): """Toggle off any button which is clicked while on. Otherwise there's always one button that's "on". """ if widget.get_active(): # TODO - cancel current operation self.tool_active = widget.name for child in self.gw_toolbar1.get_children(): if child is not widget: child.set_active(False) else: self.tool_active = None
|
op = self.active_operation = self.operations[opname](self) op.beginAt(x,y)
|
self._mousedown = 1 self.active_operation.beginAt(x,y)
|
def beginOperation(self, opname, x, y): op = self.active_operation = self.operations[opname](self) op.beginAt(x,y)
|
self.active_operation = None
|
def finishOperation(self, opname, x, y): self.active_operation.endAt(x, y) self.active_operation = None
|
|
if self.active_operation:
|
if self._mousedown:
|
def on_canvas_motion_notify_event(self, widget, ev): if self.active_operation: self.updateOperation(self.tool_active, ev.x, ev.y)
|
print self.canvas.get_size_request()
|
def displayModel(self): if self.canvas is None: self.canvas = gnomecanvas.Canvas() # make canvas draw widgets in the NW corner... self.canvas.set_center_scroll_region(False) self.gw_viewport1.add(self.canvas) self.canvas.show()
|
|
if targ is not None: return self.avatar.sendNotice(targ, {"text": messageText})
|
if target is not None: return self.avatar.sendNotice(target, {"text": messageText})
|
def irctarget_NOTICE(self, (target, messageText), prefix): if targ is not None: return self.avatar.sendNotice(targ, {"text": messageText})
|
nonrandom = dice_count + dice_optionals
|
nonrandom = (dice_count + dice_optionals)
|
def combineBonus(sign, num): values = {'-':-1, '+':1} return num * values[sign]
|
dice = (random | nonrandom).setResultsName('dice')
|
dice = (random | nonrandom).setResultsName('DICE')
|
def combineBonus(sign, num): values = {'-':-1, '+':1} return num * values[sign]
|
ParseResults object can be return instead of a scanString result.
|
ParseResults object can be returned instead of a scanString result.
|
def formatNormalized(actor, verb_phrases, targets): """Return a string with only the parts of speech, so a parseString ParseResults object can be return instead of a scanString result. """ _fm_verb_phrases = [] for vp in verb_phrases: verb_list = ' '.join(vp.verbs) if vp.dice: dice_expr = reverseFormatDice(vp.dice) elif vp.temp_modifier: dice_expr = '%+d' % (vp.temp_modifier,) else: dice_expr = '' verb_body = ' '.join((verb_list, dice_expr)) _fm_verb_phrases.append('[%s]' % (verb_body,)) fm_verb_phrases = ' '.join(_fm_verb_phrases) _fm_targets = [] for targ in targets: _fm_targets.append('@%s' % (targ,)) fm_targets = ' '.join(_fm_targets) if actor is not None: _actor = '*%s ' % (actor,) else: _actor = '' return '%s%s %s' % (_actor, fm_verb_phrases, fm_targets)
|
if vp.dice: dice_expr = reverseFormatDice(vp.dice)
|
if vp.DICE: dice_expr = reverseFormatDice(vp)
|
def formatNormalized(actor, verb_phrases, targets): """Return a string with only the parts of speech, so a parseString ParseResults object can be return instead of a scanString result. """ _fm_verb_phrases = [] for vp in verb_phrases: verb_list = ' '.join(vp.verbs) if vp.dice: dice_expr = reverseFormatDice(vp.dice) elif vp.temp_modifier: dice_expr = '%+d' % (vp.temp_modifier,) else: dice_expr = '' verb_body = ' '.join((verb_list, dice_expr)) _fm_verb_phrases.append('[%s]' % (verb_body,)) fm_verb_phrases = ' '.join(_fm_verb_phrases) _fm_targets = [] for targ in targets: _fm_targets.append('@%s' % (targ,)) fm_targets = ' '.join(_fm_targets) if actor is not None: _actor = '*%s ' % (actor,) else: _actor = '' return '%s%s %s' % (_actor, fm_verb_phrases, fm_targets)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.