本文整理汇总了Python中Euler.Euler类的典型用法代码示例。如果您正苦于以下问题:Python Euler类的具体用法?Python Euler怎么用?Python Euler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Euler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Euler
# coding:utf-8
from Euler import Euler
edu = Euler()
ts0 = edu.time()
from math import sqrt
import time
def divi(number):
sumnum=1
for x in range(2,int(sqrt(number))+1):
if number%x==0:
sumnum+=(x+number/x)
if x==number/x:
sumnum-=x
return sumnum
start=time.time()
list=[]
for x in range(1,10001):
a=divi(x)
b=divi(a)
if b==x and a!=b:
list.append(x)
count=0
for x in list:
count+=x
print list
示例2: __init__
def __init__(self, G=None, pos=None, parent=None):
QWidget.__init__(self, parent)
self.scene = GraphGraphicsScene(G, pos, self)
self.view = QGraphicsView(self.scene, self)
self.button = QPushButton("Quit", self)
self.nodeButton = QPushButton("Node", self)
self.edgeButton = QPushButton("Edge", self)
self.addButton = QPushButton("Add", self)
self.deleteButton = QPushButton("Delete", self)
self.printButton = QPushButton("Print", self)
self.eulerButton = QPushButton("Euler", self)
self.generateFullButton = QPushButton("Full", self)
self.generateHalfButton = QPushButton("Half", self)
self.infoButton = QPushButton("Info", self)
# self.testButton = QPushButton('Test', self)
self.nodesInputLabel = QLabel("Nodes", self)
self.edgesInputLabel = QLabel("Edges", self)
self.saveButton = QPushButton("Save", self)
self.loadButton = QPushButton("Load", self)
self.saveAsButton = QPushButton("SaveAs", self)
self.bridgeButton = QPushButton("Bridge", self)
self.stepSlider = QSlider(self)
self.cursorLabelX = QLabel("X:", self)
self.cursorLabelY = QLabel("Y:", self)
self.nodeNumberLabel = QLabel("Nr:", self)
self.fileLabel = QLabel("File:", self)
self.nodeInfo = QLabel("N:", self)
self.edgeInfo = QLabel("E:", self)
self.eulerInfo = QLabel("None", self)
# self.fileInput = QLineEdit(self)
self.fileInput = QLabel("", self)
self.euler = Euler()
self.eulerStep = 0
self.eulerPath = []
validator = QIntValidator(0, 10000)
self.nodesNumberInput = QLineEdit(self)
self.nodesNumberInput.setValidator(validator)
self.edgesNumberInput = QLineEdit(self)
self.edgesNumberInput.setValidator(validator)
self.cursorLabelX.setMinimumSize(150, 25)
self.cursorLabelY.setMinimumSize(150, 25)
self.nodeNumberLabel.setMinimumSize(150, 25)
self.labelsGroup = QVBoxLayout()
self.labelsGroup.addWidget(self.cursorLabelX)
self.labelsGroup.addWidget(self.cursorLabelY)
self.labelsGroup.addWidget(self.nodeNumberLabel)
HEIGHT = 50
WIDTH = 50
self.nodeButton.setFixedSize(HEIGHT, WIDTH)
self.edgeButton.setFixedSize(HEIGHT, WIDTH)
self.addButton.setFixedSize(HEIGHT, WIDTH)
self.button.setFixedSize(HEIGHT, WIDTH)
self.deleteButton.setFixedSize(HEIGHT, WIDTH)
self.printButton.setFixedSize(HEIGHT, WIDTH)
self.eulerButton.setFixedSize(HEIGHT, WIDTH)
self.generateFullButton.setFixedSize(HEIGHT, WIDTH)
self.generateHalfButton.setFixedSize(HEIGHT, WIDTH)
self.saveButton.setFixedSize(HEIGHT, WIDTH)
self.loadButton.setFixedSize(HEIGHT, WIDTH)
self.saveAsButton.setFixedSize(HEIGHT, WIDTH)
self.infoButton.setFixedSize(HEIGHT, WIDTH)
self.bridgeButton.setFixedSize(HEIGHT, WIDTH)
self.nodesNumberInput.setFixedSize(HEIGHT * 2, 28)
self.edgesNumberInput.setFixedSize(HEIGHT * 2, 28)
self.stepSlider.setFixedSize(HEIGHT * 2, 28)
# self.testButton.setFixedSize(HEIGHT, WIDTH)
self.disableSlider()
self.stepSlider.setOrientation(Qt.Horizontal)
horizontal_expanding_spacer1 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.fileGroup = QHBoxLayout()
self.fileGroup.addWidget(self.fileLabel)
self.fileGroup.addWidget(self.fileInput)
self.fileGroup.addItem(horizontal_expanding_spacer1)
self.actionsButtonGroup = QHBoxLayout()
self.actionsButtonGroup.addWidget(self.addButton)
self.actionsButtonGroup.addWidget(self.deleteButton)
self.actionsButtonGroup.addWidget(self.printButton)
self.actionsButtonGroup.addWidget(self.eulerButton)
self.actionsButtonGroup.addWidget(self.generateFullButton)
self.actionsButtonGroup.addWidget(self.generateHalfButton)
self.actionsButtonGroup.addWidget(self.saveButton)
self.actionsButtonGroup.addWidget(self.loadButton)
self.actionsButtonGroup.addWidget(self.saveAsButton)
self.actionsButtonGroup.addWidget(self.infoButton)
self.actionsButtonGroup.addWidget(self.bridgeButton)
# self.actionsButtonGroup.addWidget(self.testButton)
self.actionsButtonGroup.addWidget(self.button)
self.topGroup = QVBoxLayout()
self.topGroup.addItem(self.fileGroup)
self.topGroup.addItem(self.actionsButtonGroup)
#.........这里部分代码省略.........
示例3: Euler
# coding:utf-8
import sys
from Euler import Euler
edu = Euler()
ts0 = edu.time()
def p009():
for x in range(1,998):
for y in range(1,998):
z=1000-x-y
if z<0:
break
if x**2+y**2==z**2:
return '%d %d %d' % (x,y,z)
print p009()
print edu.time()-ts0
示例4: GraphGui
class GraphGui(QWidget):
def __init__(self, G=None, pos=None, parent=None):
QWidget.__init__(self, parent)
self.scene = GraphGraphicsScene(G, pos, self)
self.view = QGraphicsView(self.scene, self)
self.button = QPushButton("Quit", self)
self.nodeButton = QPushButton("Node", self)
self.edgeButton = QPushButton("Edge", self)
self.addButton = QPushButton("Add", self)
self.deleteButton = QPushButton("Delete", self)
self.printButton = QPushButton("Print", self)
self.eulerButton = QPushButton("Euler", self)
self.generateFullButton = QPushButton("Full", self)
self.generateHalfButton = QPushButton("Half", self)
self.infoButton = QPushButton("Info", self)
# self.testButton = QPushButton('Test', self)
self.nodesInputLabel = QLabel("Nodes", self)
self.edgesInputLabel = QLabel("Edges", self)
self.saveButton = QPushButton("Save", self)
self.loadButton = QPushButton("Load", self)
self.saveAsButton = QPushButton("SaveAs", self)
self.bridgeButton = QPushButton("Bridge", self)
self.stepSlider = QSlider(self)
self.cursorLabelX = QLabel("X:", self)
self.cursorLabelY = QLabel("Y:", self)
self.nodeNumberLabel = QLabel("Nr:", self)
self.fileLabel = QLabel("File:", self)
self.nodeInfo = QLabel("N:", self)
self.edgeInfo = QLabel("E:", self)
self.eulerInfo = QLabel("None", self)
# self.fileInput = QLineEdit(self)
self.fileInput = QLabel("", self)
self.euler = Euler()
self.eulerStep = 0
self.eulerPath = []
validator = QIntValidator(0, 10000)
self.nodesNumberInput = QLineEdit(self)
self.nodesNumberInput.setValidator(validator)
self.edgesNumberInput = QLineEdit(self)
self.edgesNumberInput.setValidator(validator)
self.cursorLabelX.setMinimumSize(150, 25)
self.cursorLabelY.setMinimumSize(150, 25)
self.nodeNumberLabel.setMinimumSize(150, 25)
self.labelsGroup = QVBoxLayout()
self.labelsGroup.addWidget(self.cursorLabelX)
self.labelsGroup.addWidget(self.cursorLabelY)
self.labelsGroup.addWidget(self.nodeNumberLabel)
HEIGHT = 50
WIDTH = 50
self.nodeButton.setFixedSize(HEIGHT, WIDTH)
self.edgeButton.setFixedSize(HEIGHT, WIDTH)
self.addButton.setFixedSize(HEIGHT, WIDTH)
self.button.setFixedSize(HEIGHT, WIDTH)
self.deleteButton.setFixedSize(HEIGHT, WIDTH)
self.printButton.setFixedSize(HEIGHT, WIDTH)
self.eulerButton.setFixedSize(HEIGHT, WIDTH)
self.generateFullButton.setFixedSize(HEIGHT, WIDTH)
self.generateHalfButton.setFixedSize(HEIGHT, WIDTH)
self.saveButton.setFixedSize(HEIGHT, WIDTH)
self.loadButton.setFixedSize(HEIGHT, WIDTH)
self.saveAsButton.setFixedSize(HEIGHT, WIDTH)
self.infoButton.setFixedSize(HEIGHT, WIDTH)
self.bridgeButton.setFixedSize(HEIGHT, WIDTH)
self.nodesNumberInput.setFixedSize(HEIGHT * 2, 28)
self.edgesNumberInput.setFixedSize(HEIGHT * 2, 28)
self.stepSlider.setFixedSize(HEIGHT * 2, 28)
# self.testButton.setFixedSize(HEIGHT, WIDTH)
self.disableSlider()
self.stepSlider.setOrientation(Qt.Horizontal)
horizontal_expanding_spacer1 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.fileGroup = QHBoxLayout()
self.fileGroup.addWidget(self.fileLabel)
self.fileGroup.addWidget(self.fileInput)
self.fileGroup.addItem(horizontal_expanding_spacer1)
self.actionsButtonGroup = QHBoxLayout()
self.actionsButtonGroup.addWidget(self.addButton)
self.actionsButtonGroup.addWidget(self.deleteButton)
self.actionsButtonGroup.addWidget(self.printButton)
self.actionsButtonGroup.addWidget(self.eulerButton)
self.actionsButtonGroup.addWidget(self.generateFullButton)
self.actionsButtonGroup.addWidget(self.generateHalfButton)
self.actionsButtonGroup.addWidget(self.saveButton)
self.actionsButtonGroup.addWidget(self.loadButton)
self.actionsButtonGroup.addWidget(self.saveAsButton)
self.actionsButtonGroup.addWidget(self.infoButton)
self.actionsButtonGroup.addWidget(self.bridgeButton)
# self.actionsButtonGroup.addWidget(self.testButton)
self.actionsButtonGroup.addWidget(self.button)
self.topGroup = QVBoxLayout()
self.topGroup.addItem(self.fileGroup)
#.........这里部分代码省略.........
示例5: avg
nodeCount = sys.argv[nodeIndex + 1]
edgeIndex = sys.argv.index("-e")
edgeCount = sys.argv[edgeIndex + 1]
t = timeit.Timer("Generator().generate_half_euler_graph("+nodeCount+","+edgeCount+")",
"from Generator import Generator")
times = t.repeat(5,10)
print avg(times)
elif s == "-i":
dFile = sys.argv.index("-i")
fileTemp = sys.argv[dFile+1]
graphFile = GraphFile(fileTemp)
(G, pos, nodesNumber, edgesNumber) = graphFile.load()
euler = Euler()
(info,odds) = euler.checkGraph(G)
print info
print "Edges: "+str(nodesNumber)
print "Nodes: "+str(edgesNumber)
elif s == "-e":
dFile = sys.argv.index("-e")
fileTemp = sys.argv[dFile+1]
graphFile = GraphFile(fileTemp)
(G, pos, nodesNumber, edgesNumber) = graphFile.load()
euler = Euler()
path = euler.start(G)
print path
elif s == "-et":