Example #1
0
def play_game(game, *players):
    "Play an n-person, move-alternating game."
    #timing added from timing.py
    timing.start()
    state = game.initial
    while True:
        for player in players:
            move = player(game, state)
            state = game.make_move(move, state)
            if game.terminal_test(state):
                game.display(state)
                timing.finish()
                sec = timing.seconds()
                thousandths = (timing.milli() % 1000) 
                #print "\n{0}.{1} seconds\n\n".format(sec, thousandths)
                return game.end_game(game.utility(state, players[0]), state)
Example #2
0
def play_game(game, *players):
    "Play an n-person, move-alternating game."
    #timing added from timing.py
    timing.start()
    state = game.initial
    while True:
        for player in players:
            move = player(game, state)
            state = game.make_move(move, state)
            if game.terminal_test(state):
                game.display(state)
                timing.finish()
                sec = timing.seconds()
                thousandths = (timing.milli() % 1000)
                #print "\n{0}.{1} seconds\n\n".format(sec, thousandths)
                return game.end_game(game.utility(state, players[0]), state)
Example #3
0
File: tmpc.py Project: gaving/tmpc
    def __init__(self):
        if not pynotify.init("Init"):
            debug("Error: Failed to initialize pynotify.")
            sys.exit(1)

        parser = OptionParser(usage="%prog [options]", version="0.1",
                              description="Tray based notifier for MPD.")
        parser.add_option('-v', dest='verbosity', help='Display debugging output', 
                action="store_const", const=1)
        parser.add_option('-d', '--disable-lastfm', dest='lastfm', 
                help='Disable lastfm functionality', action="store_false")
        parser.add_option('-l', '--disable-lyrics', dest='lyrics', 
                help='Disable lyrics functionality', action="store_false")
        parser.set_defaults(**DEFAULTS)
        (option_obj, args) = parser.parse_args()
        
        options = {}
        options['verbosity'] = option_obj.verbosity
        options['lastfm'] = option_obj.lastfm
        options['lyrics'] = option_obj.lyrics

        # FIXME: Ewww.
        global DEBUG_LVL
        DEBUG_LVL = options['verbosity']

        print options

        self.track = {}
        self.artist_url = None
        self.title_url = None
        self.uri = None
        self.tray = None
        
        self.menu = None
        self.buttons = None
        self.box = None
        self.n = None

        self.recent_tracks = []
        self.recent_tracks_menu = None
        self.friends_menus = {}
       
        # Initialize 'modules'
        self.lastfm = Lastfm()
        self.lyrics = Lyrics()
            
        debug("* Populating playlist...")
        timing.start()
        self.playlist = mpdclient2.connect().playlistinfo()
        timing.finish()
        debug("..done. (%d seconds)" % timing.seconds())
        
        if options['lastfm']:
            debug("* Enabling last.fm functionality")
            self.lastfm.enable()

            debug("* Fetching recently played tracks")
            self.recent_tracks = self.lastfm.fetch_recent_tracks(LAST_FM['USERNAME'])

            debug("* Starting friend grabs every minute")
            gobject.timeout_add(60000, self.lastfm.sched_friends_data)
        
        if options['lyrics']:
            debug("* Enabling lyrics functionality")
            self.lyrics.enable()

        self.create_tray()
            
        # Check for track change every second
        gobject.timeout_add(1000, self.check_for_change)
Example #4
0
                          a0=0.3, mesh_bounding_box=True,

                          fixed_points = fix,

                          max_steps = N,

                          density = density,

                          neigh_force_scale = 0.0,

                          shape_force_scale = shape_elem,

                          volume_force_scale = 0.0
                          )
        timing.finish()
        time.append(timing.seconds())
        #iteration.append(N)

        #save the mesh as a .ps file in temp dir
        nmesh.visual.plot2d_ps(mesh,"fig_mesh_shape_%d_iter%06d.ps"\
                               % (shape_elem,N) ) 

        #extract the mesh data from mesh_info
        mesh_info = mesh.tolists()
        vtkData, points, simplices, simplexIndicies, icradii, ccradii=\
                 nmesh.visual.mesh2vtk(mesh_info, VTKonly=False)
        in2circ = nmesh.visual.findRatios(icradii, ccradii, factor=2)#2D

        #count the number of point after iterations and add to list
        nodes.append(len(points))
Example #5
0
  `gi_id` varchar(3000) NOT NULL,
  `ref_seq_ac` varchar(1000) NOT NULL,
  `ref_seq_def` varchar(1000) NOT NULL,
  `go_ids` varchar(3000) NOT NULL,
  `go_terms` varchar(12000) NOT NULL,
  `go_ontology` varchar(100) NOT NULL,
  `uniprot_ac` varchar(50) NOT NULL,
  `uniprot_def` varchar(300) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Tabla con los campos definitivos';"""

#query = table.format('morrongo')
#print query
#dbh.executeSQL(query);
timing.start()
result = dbh.executeSQL('select * from Diploria_datos limit 0,250000')
countd = dbh.executeSQL('select count(*) as count from Diploria_datos')
print countd[0]['count']
slices = countd[0]['count']/250000
print slices
timing.finish()
print "Took: "+str(timing.seconds())+" seconds to complete"
sconds_t = timing.seconds()*slices
print "Estimate to complete all records: "+str(sconds_t/60)+' minutes'




#print result
#print sys.getsizeof(result)/1000
#print len(result);
Example #6
0
from test_support import verbose
import timing

r = range(100000)
if verbose:
    print 'starting...'
timing.start()
for i in r:
    pass
timing.finish()
if verbose:
    print 'finished'

secs = timing.seconds()
milli = timing.milli()
micro = timing.micro()

if verbose:
    print 'seconds:', secs
    print 'milli  :', milli
    print 'micro  :', micro
Example #7
0

                          #tolerated_rel_move = 0.0009,

                          max_steps = N,

                          density = density,

                          neigh_force_scale = neigh_force,

                          shape_force_scale = shape_force,

                          volume_force_scale = 0.0
                          )
        timing.finish()
        time.append(timing.seconds())

        # save mesh
        mesh.save("edge_shape_%d.nmesh" % e)

        # load mesh from file
        #mesh_loaded = nmesh.load("save_load.nmesh")

        # plot loaded mesh
        #nmesh.visual.plot2d_ps(mesh_loaded,"save_load.ps")

        #save the mesh as a .ps file in temp dir
        nmesh.visual.plot2d_ps\
             (mesh,"fig_mesh_edge_shape_%d_iter%06d.ps" % (e,N))

        #extract the mesh data from mesh_info
Example #8
0
import timing
import time

def procedure():
    time.sleep(1.234)

timing.start()
procedure()
timing.finish()

print "seconds:", timing.seconds()
print "milliseconds:", timing.milli()
print "microseconds:", timing.micro()

## seconds: 1
## milliseconds: 1239
## microseconds: 1239999
Example #9
0
            tol=0.000005,
            dt=1.0,
            hbsize=1000,
            nlag=1,
            nsw=2,
            ssc=ddestsc)

#print sdde_eg.data

odetitles = ["prey", "predators"]
sddetitles = [r"\large resources", r"\large consumers"]
ddetitles = ["blowflies"]

if timeit:
    timing.finish()
    print(str(timing.seconds()) + "." + str(timing.milli()) + " seconds")

try:
    from pyx import *
    '''
    Print the ODE model
    '''
    odepp = graph.graphxy(width=15,
                          height=12,
                          x=graph.axis.linear(min=0,
                                              max=300,
                                              title=r"time $t$"),
                          y=graph.axis.linear(min=0,
                                              max=220,
                                              title=r"population sizes"),
                          key=graph.key.key(pos="tl"))
Example #10
0
from test_support import verbose
import timing
r = range(100000)
if verbose:
    print 'starting...'
timing.start()
for i in r:
    pass
timing.finish()
if verbose:
    print 'finished'
secs = timing.seconds()
milli = timing.milli()
micro = timing.micro()
if verbose:
    print 'seconds:', secs
    print 'milli  :', milli
    print 'micro  :', micro
Example #11
0
import timing
import time


def procedure():
    time.sleep(1.234)


timing.start()
procedure()
timing.finish()

print("seconds:", timing.seconds())
print("milliseconds:", timing.milli())
print("microseconds:", timing.micro())

## seconds: 1
## milliseconds: 1239
## microseconds: 1239999
Example #12
0
           switchfunc=sddesw, mapfunc=sddemaps,
           tol=0.000005, dt=1.0, hbsize=1000, nlag=1, nsw=2, ssc=ddestsc)

#print sdde_eg.data





odetitles = ["prey", "predators"]
sddetitles = [r"\large resources", r"\large consumers"]
ddetitles = ["blowflies"]

if timeit:
    timing.finish()
    print(str(timing.seconds())+"."+str(timing.milli())+" seconds")
    
    
try:
    from pyx import *

    '''
    Print the ODE model
    '''
    odepp = graph.graphxy(width=15, height=12,
                          x=graph.axis.linear(min=0,
                                              max=300,
                                              title=r"time $t$"),
                          y=graph.axis.linear(min=0,
                                              max=220,
                                              title=r"population sizes"),
Example #13
0
  `alig_score` float NOT NULL,
  `alig_bitscore` float NOT NULL,
  `alig_identy` float NOT NULL,
  `gi_id` varchar(3000) NOT NULL,
  `ref_seq_ac` varchar(1000) NOT NULL,
  `ref_seq_def` varchar(1000) NOT NULL,
  `go_ids` varchar(3000) NOT NULL,
  `go_terms` varchar(12000) NOT NULL,
  `go_ontology` varchar(100) NOT NULL,
  `uniprot_ac` varchar(50) NOT NULL,
  `uniprot_def` varchar(300) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Tabla con los campos definitivos';"""

#query = table.format('morrongo')
#print query
#dbh.executeSQL(query);
timing.start()
result = dbh.executeSQL('select * from Diploria_datos limit 0,250000')
countd = dbh.executeSQL('select count(*) as count from Diploria_datos')
print countd[0]['count']
slices = countd[0]['count'] / 250000
print slices
timing.finish()
print "Took: " + str(timing.seconds()) + " seconds to complete"
sconds_t = timing.seconds() * slices
print "Estimate to complete all records: " + str(sconds_t / 60) + ' minutes'

#print result
#print sys.getsizeof(result)/1000
#print len(result);