当前位置: 首页>>代码示例>>Python>>正文


Python table.Table类代码示例

本文整理汇总了Python中table.Table的典型用法代码示例。如果您正苦于以下问题:Python Table类的具体用法?Python Table怎么用?Python Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestPot

class TestPot(unittest.TestCase):
    """Do we have a fully functional pot object?"""

    def setUp(self):
        self.p0 = Player('p0', 100)
        self.p1 = Player('p1', 100)
        self.p2 = Player('p2', 100)
        self.p3 = Player('p3', 100)
        self.p4 = Player('p4', 100)
        self.p5 = Player('p5', 100)

        self.s0 = Seat('s0')
        self.s1 = Seat('s1')
        self.s2 = Seat('s2')
        self.s3 = Seat('s3')
        self.s4 = Seat('s4')
        self.s5 = Seat('s5')

        players = [self.p0, self.p1, self.p2, self.p3, self.p4, self.p5]
        seats = [self.s0, self.s1, self.s2, self.s3, self.s4, self.s5]

        self.table = Table(seats, 5, 10, 0)
        self.dealer = Dealer(self.table)
        self.table.dealer = self.dealer

        player = 0
        for seat in seats:
            seat.player = players[player]
            seat.player.seat = seat
            seat.active = True
            seat.player.table = self.table
            player += 1
        self.table.init_hand()

    def test_who_is_first_pre_flop(self):
        """Do we make the proper player act first pre-flop??"""
        self.dealer.deal_hole()
        self.assertTrue(self.table.seats[self.table.under_the_gun].player.action)

    def test_who_is_first_post_flop(self):
        """Do we make the proper player act first post-flop"""
        self.dealer.deal_hole()
        self.table.seats[self.table.under_the_gun].player.action = False
        self.dealer.deal()
        self.assertTrue(self.table.seats[self.table.first].player.action)

    def test_bet(self):
        """Can each player bet 50?"""
        self.dealer.deal_hole()
        i = 0
        while i < 6:
            i += 1
            for seat in self.table.pots[-1].seats:
                print(seat.player.name, seat.player.equity, seat.player.action)
                if seat.player.action:
                    seat.player.bet(50)
                    self.table.pots[-1].betting_round()
                    break
                print(seat.player.name, seat.player.equity, seat.player.action)
        print(self.table.pots[-1].pot)
开发者ID:mrbubba,项目名称:Poker,代码行数:60,代码来源:test_pot.py

示例2: _on_register

    def _on_register(self, username):
        self.nick = username
        self.send({'registered': self.nick})
        #score = self._get_score(self.nick)
        #self.send({'update_score': score})
        while self._waiting:
            opponent = self._waiting.pop()
            if opponent.is_closed:
                continue

            self._opponents[self.session].append(opponent)
            self._opponents[opponent.session].append(self)
            self.send({'status': "playing against " + opponent.nick,
                       'ready': True})
            opponent.send({'status': "playing against " + self.nick,
                           'ready': True})

            table_id = Table.new_table_id()
            players = [self, opponent]
            for player in players:
                player.table_id = table_id
                player.changes = 0
            table = Table(players)
            self._tables[table_id] = table # could be more
            table.deal_5_cards_each()
            for player in table.players:
                player.send({'hand': player.cards})

        else:
            self._waiting.append(self)
            self.send({'status': 'Waiting', 'color': 'orange'})
开发者ID:peterbe,项目名称:chicago,代码行数:31,代码来源:sock_app.py

示例3: generate_time_table

    def generate_time_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        # get data
        for procedure in self.data.procedures:
            data = self.data.data_for_procedure(procedure)
            row = [procedure]

            for item in data:
                fmt = TIME_PATTERN % item.time
                if item.time == self.data.get_shortest_time(item.size):
                    row.append('**%s**' % fmt)
                else:
                    row.append(fmt)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:26,代码来源:report.py

示例4: display_addr_refs

def display_addr_refs(refs, ref_statuses):

    table = Table(
        num_cols=len(REF_COL_NAMES), width=TABLE_WIDTH, alignment='right')
    table.header[:] = REF_COL_NAMES

    for ref, ref_status in zip(refs, ref_statuses):

        if ref.tag is not None:
            ref_tag = ref.tag
        else:
            ref_tag = 'n/a'

        if ref.index is not None:
            ref_index = ref.index
        else:
            ref_index = 'n/a'

        if ref.offset is not None:
            ref_offset = ref.offset
        else:
            ref_offset = 'n/a'

        # Display data for each address as a row in the table
        table.rows.append((
            ref.word_addr,
            prettify_bin_addr(ref.bin_addr, MIN_BITS_PER_GROUP),
            prettify_bin_addr(ref_tag, MIN_BITS_PER_GROUP),
            prettify_bin_addr(ref_index, MIN_BITS_PER_GROUP),
            prettify_bin_addr(ref_offset, MIN_BITS_PER_GROUP),
            ref_status))

    print(table)
开发者ID:chubbymaggie,项目名称:cache-simulator,代码行数:33,代码来源:simulator.py

示例5: format_table

def format_table(data):
    table = Table()
    keys  = data[1].keys()

    # prepare header
    header1 = ["number of spaces"]
    header2 = [""]
    for key in keys:
        header1.append(("%s [cycles/byte]" % key, 3))
        header2.extend(["avg (min)", "avg (max)", "best"])

    table.add_header(header1)
    table.add_header(header2)

    # add data
    for cardinality in xrange(1, 64+1):
        row = ['%d' % cardinality]
        measurements = data[cardinality]
        for meas in measurements.values():
            row.append('%0.3f' % min(meas.values))
            row.append('%0.3f' % max(meas.values))
            row.append('%0.3f' % meas.best)

        table.add_row(row)

    return table
开发者ID:WojciechMula,项目名称:toys,代码行数:26,代码来源:format.py

示例6: load_table

def load_table(filename):
    t = Table()

    seen_header = False
    for line in file(filename):
        if not seen_header:
            seen_header = True
            continue

        line = line.rstrip("\n")
        (id, status, price, genres, policy, countries) = line.split("\t")

        def split_ints(commasep):
            if commasep == '':
                return set()
            return set([int(s) for s in commasep.split(",")])

        t.append_row(
            id,
            {
            'status': status,
            'price': int(float(price)*100),
            'genre': split_ints(genres),
            'policy': policy,
            'country': split_ints(countries)
            })

    return t
开发者ID:toddlipcon,项目名称:bitserve,代码行数:28,代码来源:tsv_test.py

示例7: generate_speedup_table

    def generate_speedup_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        reference_time = {}
        for size in self.data.sizes:
            time = self.data.get(self.data.procedures[0], size)
            reference_time[size] = time

        # get data
        for proc in self.data.procedures:
            measurments = self.data.data_for_procedure(proc)

            row = [proc]
            for item in measurments:
                speedup = reference_time[item.size] / item.time
                row.append('%0.2f' % speedup)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:28,代码来源:report.py

示例8: reset

 def reset(cls):
   """Reset to default state."""
   Box.reset()
   Note.reset()
   Figure.reset()
   Table.reset()
   Video.reset()
开发者ID:nunb,项目名称:MaTiSSe,代码行数:7,代码来源:theme.py

示例9: result

    def result(self):
        """ Perform the query, and return the result as a Table object """

        BaseQuery.logger.log( "With arguments: " + str(self.arguments) )
        BaseQuery.logger.log( "Running query: \n" + str(self.complete_query) )

        cursor = self.db_connection.cursor()

        start_time = time.time()
        cursor.execute( self.complete_query ) 
        self.elapsed_time = time.time() - start_time

        BaseQuery.logger.log( str(self.elapsed_time) + " seconds" )

        results_table = Table()
        
        for col in cursor.description:
            results_table.append_column( col[0] )

        row = cursor.fetchone()
        while row:
            results_table.append_row( [self.output_clean_function(i) for i in row] )
            row = cursor.fetchone()

        self.rows_fetched = len(results_table) 

        BaseQuery.logger.log( str(self.rows_fetched) + " rows fetched" )

        return results_table
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:29,代码来源:query.py

示例10: createTable

def createTable(**kwargs):
    """ CREATE table.
    kwargs['cols'] is a list of consecutive column name - type pairs
    i.e. [col1_name, col1_type, col2_name, col2_type, ...] which is why
    it gets split when calling Table.create()
    """

    Table.create(kwargs['table'], kwargs['cols'][::2], kwargs['cols'][1::2])
开发者ID:heikkiv,项目名称:trak,代码行数:8,代码来源:queryproc.py

示例11: login

    def login(self, *args):
        global w
        name = w.loginEdit.text()
        password = w.passwordEdit.text()

        if User.login(name, password):
            w = Table()
            w.show()
开发者ID:aaveter,项目名称:curs_2016_b,代码行数:8,代码来源:buh3.py

示例12: test_get_table

 def test_get_table(self):
     try:
         data = TG.build_table_from_txt(D.analog_1)
         table = Table(data)
         check = table.get_table()
         self.assertIs(data, check)
     except:
         self.assert_(False)
开发者ID:NFJones,项目名称:pyWave,代码行数:8,代码来源:unit_tests.py

示例13: test_get_length

 def test_get_length(self):
     try:
         data = TG.build_table_from_txt(D.analog_1)
         table = Table(data)
         length = table.get_length()
         self.assertEqual(len(data), length)
     except:
         self.assert_(False)
开发者ID:NFJones,项目名称:pyWave,代码行数:8,代码来源:unit_tests.py

示例14: apply

	def apply(self, tables):

		columns = self.get_columns(tables)
		table = tables[0]
		
		measure_column = table[self['measure']]
		
		new_column_headers = []
		header_column = columns[0]
		start_row = 0
		end_row = table.rows()

		for v in header_column.data:
			if(not v in new_column_headers):
				new_column_headers.append(v)
		

		
		key_columns = filter(lambda x: not x.name in [measure_column.name, header_column.name], table)

		reduction = {}
		reduction_index = 0
		
		new_table = Table()
		
		for col in key_columns:
			new_table.add_column(col.name, {})
		
		#this name lookup is needed since table implementation changes names under certain circumstances
		name_lookup = {}
		for header in new_column_headers:
			col = new_table.add_column(header, {})
			name_lookup[header] = col.name
		
		
		for row in range(start_row, end_row):
			key = '*'.join([col[row] for col in key_columns])
			if(not reduction.has_key(key)):
				reduction[key] = reduction_index
				
				for col in key_columns:
					new_table[col.name][reduction_index] = col[row]
				
				reduction_index += 1

			index = reduction[key]
			header = header_column[row]
			measure = measure_column[row]
			
			
			new_table[name_lookup[header]][index] = measure


		table.clear()
		
		for col in new_table:
			table.insert_column(col, {})
开发者ID:tfmorris,项目名称:wrangler,代码行数:57,代码来源:unfold.py

示例15: __call__

 def __call__(self, category, player_id, dct):
     table_name = 'gc_cur_team_stats_{0}'.format(category)
     table = Table(table_name)
     table.insert(
         self.cursor,
         getattr(values, table_name)(
             self.gc_cur_team_id,
             player_id,
             dct))
开发者ID:jthomm,项目名称:landeta,代码行数:9,代码来源:landeta.py


注:本文中的table.Table类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。