Best Python code snippet using fMBT_python
many_timeseries.py
Source:many_timeseries.py
...14 'global': dict(rasterized=True),15 }16 if 'all' in show:17 # plot individual traces before the rest18 kwargs = self._getopts(opts,'all')19 for ysi in ys:20 ax.plot( times, ysi, **kwargs)21 if 'mean' in show or 'std' in show:22 meany = np.mean( ys, axis=0 )23 if 'std' in show:24 # plot std before mean so it is behind25 kwargs = self._getopts(opts,'std')26 stdy = np.std( ys, axis=0 )27 ax.fill_between( times, meany+stdy, meany-stdy, **kwargs)28 if 'mean' in show:29 kwargs = self._getopts(opts,'mean')30 ax.plot( times, meany, **kwargs)31 def _getopts(self,opts,name):32 result = {}33 # apply the defaults first34 result.update( self.default_opts['global'] )35 result.update( self.default_opts[name] )36 # then apply the options passed on this run37 result.update( opts.get('global',{}) )38 result.update( opts.get(name, {}) )39 return result40 def finalize(self):...
ai.py
Source:ai.py
1#!/usr/bin/env python2import sys, optparse, utils, os, socket3from protocol import Protocol4class Core:5 def _getopts(self):6 parser = optparse.OptionParser()7 parser.add_option('-a', '--host', dest='host', help='host to connect', default='localhost')8 parser.add_option('-p', '--port', dest='port', type='int', help='port to use')9 parser.add_option('-n', '--team', dest='team', help='the team name')10 parser.add_option('-t', '--term', dest='term', help='set a terminal path (will be open for each new drone)', default=False)11 opts, args = parser.parse_args()12 if not (opts.host and opts.port and opts.team):13 parser.print_help()14 print('\nError: missing options.')15 print sys.exit(0)16 utils.term = opts.term17 return (opts.host, opts.port, opts.team)18 def run(self):19 (host, port, team) = self._getopts()20 try:21 self.protocol = Protocol(host, port, team)22 self.protocol.run()23 except (socket.error, socket.gaierror), (value, message):24 print('Connection error: %s (%d)' % (message, value))25 except Exception, e:26 print('Error: %s' % e)27if __name__ == '__main__':28 try:29 os.chdir(os.path.dirname(__file__))30 c = Core()31 c.run()32 except KeyboardInterrupt:33 print('\nQuitting...')
ai
Source:ai
1#!/usr/bin/env python2import sys, optparse, utils, os, socket3from protocol import Protocol4class Core:5 def _getopts(self):6 parser = optparse.OptionParser()7 parser.add_option('-a', '--host', dest='host', help='host to connect', default='localhost')8 parser.add_option('-p', '--port', dest='port', type='int', help='port to use')9 parser.add_option('-n', '--team', dest='team', help='the team name')10 parser.add_option('-t', '--term', dest='term', help='set a terminal path (will be open for each new drone)', default=False)11 opts, args = parser.parse_args()12 if not (opts.host and opts.port and opts.team):13 parser.print_help()14 print('\nError: missing options.')15 print sys.exit(0)16 utils.term = opts.term17 return (opts.host, opts.port, opts.team)18 def run(self):19 (host, port, team) = self._getopts()20 try:21 self.protocol = Protocol(host, port, team)22 self.protocol.run()23 except (socket.error, socket.gaierror), (value, message):24 print('Connection error: %s (%d)' % (message, value))25 except Exception, e:26 print('Error: %s' % e)27if __name__ == '__main__':28 try:29 os.chdir(os.path.dirname(__file__))30 c = Core()31 c.run()32 except KeyboardInterrupt:33 print('\nQuitting...')
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!