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


Python Matrix.__repr__方法代码示例

本文整理汇总了Python中Matrix.__repr__方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.__repr__方法的具体用法?Python Matrix.__repr__怎么用?Python Matrix.__repr__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


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

示例1: Breadboard

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import __repr__ [as 别名]

#.........这里部分代码省略.........
	
	def detailLocations(self):
		"""assigns display flags, which are for coloring the GUI.
		Sets the Location objects at coordinates at which there are no pins 
		to Filled.
		adds voltage at the rails"""
				
		for x in range(self.numColumns):
			for y in range(self.numRows):
				if y==2: #fills pins between rows
					self.setFilled(x,y)
					self.setDisplayFlag(x,y,Location.BLUE_LINE)
				if y==15:
					self.setFilled(x,y)
					self.setDisplayFlag(x,y,Location.RED_LINE)
				if y==8:
					self.setFilled(x,y)
					self.setDisplayFlag(x,y,Location.CENTER_BOTTOM)
				if y==9:
					self.setFilled(x,y)
					self.setDisplayFlag(x,y,Location.CENTER_TOP)
				if (x+1)%6==0 and (y==0 or y==1 or y==16 or y==17): #fills pins between power fivesomes
					self.setFilled(x,y)
					self.setDisplayFlag(x,y,Location.BLANK)
				if y==0:	
					self.setNodeVoltage(x,y,self.rails[3])	#sets power at top rail
				if y==1:
					self.setNodeVoltage(x,y,self.rails[2])	#sets power at second from top rail
				if y==16:
					self.setNodeVoltage(x,y,self.rails[1])	#sets power at third from top rail
				if y==17:
					self.setNodeVoltage(x,y,self.rails[0])	#sets power at bottom rail
					
	def __repr__(self):
		"""returns all Locations"""
		return self.locMatrix.__repr__() 
		
	def setNodeVoltage(self,x,y,voltage,voltageType='DC',frequency=0):
		"""changes the Voltage object a particular Location's Node"""
		self.getLocation(x,y).Node.voltage = Voltage(voltage,voltageType,frequency)
		return True

	
	def clearNodeVoltage(self,x,y):
		"""sets the Voltage at a Location's Node to zero."""
		self.setNodeVoltage(x,y,0)
		return True
	
	def getNodeVoltage(self,x,y):
		"""returns Voltage at a Location"""
		return self.getLocation(x,y).Node.voltage

	def isFilled(self,x,y):
		"""tells if a pin at a certain Location is filled"""
		return self.getLocation(x,y).isFilled

	def setFilled(self,x,y):
		"""fills a pin at a Location"""
		self.getLocation(x,y).isFilled = True
	
	def setDisplayFlag(self,x,y,displayFlag):
		"""a helper function for setting the color of certain pins in 
		the BB"""
		self.getLocation(x,y).setDisplayFlag(displayFlag)

	def setUnfilled(self,x,y):
开发者ID:ProjectArchive,项目名称:MinchsMagicStoreyLand,代码行数:70,代码来源:Breadboard.py


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