本文整理汇总了Python中Grid.Grid.append方法的典型用法代码示例。如果您正苦于以下问题:Python Grid.append方法的具体用法?Python Grid.append怎么用?Python Grid.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid.Grid
的用法示例。
在下文中一共展示了Grid.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeGrid
# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import append [as 别名]
def initializeGrid(self, M, n):
"""Grid initizialed by funtions startLevel and startState
Function takes the number of species M and dims of the
2-D lattice (n by n)"""
grid = Grid()
for i in range(n):
row = []
for j in range(n):
row.append(Cell(self,self.startLevel(M), self.startState()))
grid.append(row)
return grid
示例2: reorderGrid
# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import append [as 别名]
def reorderGrid(self, grid):
"""The lowest level species shoud have the highest occurence, make it
so"""
numbers = []
for i in range(self.M):
numbers.append([i, 0])
for row in grid:
for cell in row:
numbers[cell.Level][1] += 1
numbers = sorted(numbers, key=lambda x: x[1], reverse=True)
new_Grid = Grid()
for row in grid:
new_row = []
for cell in row:
for i in range(len(numbers)):
if numbers[i][0] == cell.Level:
new_row.append(Cell(self, i, cell.State))
break
new_Grid.append(new_row)
return new_Grid