def main(): global objArr, isRunning, projection, camera createWindow() projection = glGetFloatv(GL_PROJECTION_MATRIX) # MATRICES VALUES.... camera = CameraManagement.Camera(projection) # Creates objects at origin 0,0,0 cube = Shapes.Cube(5) rectangle = Shapes.Rectangle(5, 5, 4, -5, 1, -2) pyramid = Shapes.Pyramid(-3, -4, 1) objArr = {cube, rectangle, pyramid} isRunning = True while isRunning: projection = glGetFloatv(GL_PROJECTION_MATRIX) #print (projection) glLoadIdentity try: glLoadMatrixf(camera.getMapped()) except: """""" getKeys() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) for i in objArr: i.update() i.updateColor() #UPDATES DIMENSIONS OF EACH OBJECT pygame.display.flip() pygame.time.wait(50)
def __init__(self, center=(0, 0), width=5000, height=5000, power=45, freq=20, speed=25000): super(LaseredFiducial, self).__init__() if isinstance(center, tuple) == False: raise ValueError( 'parameter center must be a tuple of x and y position!') if Utils._checkIfIntFloatOrLong( center[0]) == False or Utils._checkIfIntFloatOrLong( center[1]) == False: raise ValueError('x and y of center must be long or int!') xstart = center[0] - width / 2.0 xend = center[0] + width / 2.0 ystart = center[1] - height / 2.0 yend = center[1] + height / 2.0 self.addElement( Shapes.LaserLine((xstart, center[1]), (xend, center[1]), power, freq, speed)) self.addElement( Shapes.LaserLine((center[0], ystart), (center[0], yend), power, freq, speed))
def fractest(self, item, it=3): self.frac_choice = item if not self.F_c_v: self.F_c_v = True mb = Menubutton(self.fracsubframe, text="Iterations") mb.grid() mb.menu = Menu(mb, tearoff=0) mb["menu"] = mb.menu for x in range(3, 7): mb.menu.add_command( label="%s" % x, command=lambda x=x: self.fractest(self.frac_choice, x)) mb.pack(side=BOTTOM, anchor=W) if item == 1: sq = Shapes.RegPoly(150, 4) sq.set_center(175, 175) sq.vertices(0) draw.sierpinski_sq_start(self.fraccr, sq, it) if item == 2: draw.t_frac_start(self.fraccr, it) elif item == 0: sq = Shapes.RegPoly(160, 3) sq.set_center(175, 175) sq.vertices(0) draw.s_gasket_start(self.fraccr, sq, it)
class TestShapes(unittest.TestCase): # Select a shape: # 1. Circle # 2. Square # 3. Rhombus # 4. Cube # 5. Cylinder # After basic size information is entered, the program will output # circumference/area/volume # of the shape, and the number of sides for the shape. @classmethod def setUp(self): self.shapes = Shapes() def test_circle_circumfrence(self): self.assertEqual(self.shapes.create_circle(4), 25.13) def test_square_volume(self): self.assertEqual(self.shapes.create_square(4), 16) def test_Rhombus_area(self): self.assertEqual(self.shapes.create_rhombus(4,4), 8) def test_cube_surface_area(self): self.assertEqual(self.shapes.create_cube(4), 64) def test_cylinder_volume(self): self.assertEqual(self.shapes.create_cylinder(4,4), 200.96)
def setShapes(self, shapeNum, x_offset, y_offset, x_width, y_width, angle): if shapeNum == 1: self.shape1_x = x_offset self.shape1_y = y_offset self.shape1_width = x_width self.shape1_height = y_width self.shape1_angle = angle self.shape1 = Shapes.AngledBox(self.x_init + self.shape1_x, self.y_init + self.shape1_y, self.shape1_width, self.shape1_height, angle) elif shapeNum == 2: self.shape2_x = x_offset self.shape2_y = y_offset self.shape2_width = x_width self.shape2_height = y_width self.shape2_angle = angle self.shape2 = Shapes.AngledBox(self.x_init + self.shape2_x, self.y_init + self.shape2_y, self.shape2_width, self.shape2_height, angle) elif shapeNum == 3: self.shape3_x = x_offset self.shape3_y = y_offset self.shape3_width = x_width self.shape3_height = y_width self.shape3_angle = angle self.shape3 = Shapes.AngledBox(self.x_init + self.shape3_x, self.y_init + self.shape3_y, self.shape3_width, self.shape3_height, angle) else: print "ERROR INCORRECT SHAPE NUMBER RECEIVED IN SET SHAPES"
def mousePressEvent(self, event): #randomly choose a shape to draw shapenum = randint(0, 4) if shapenum == 0: #information to draw Rectangle rect = Shapes.Rectangle(event.x(), event.y()) self.__shapes.append(rect) elif shapenum == 1: #information to draw Squares square = Shapes.Squares(event.x(), event.y()) self.__shapes.append(square) elif shapenum == 2: #information to draw Ellipse elpse = Shapes.Ellipses(event.x(), event.y()) self.__shapes.append(elpse) elif shapenum == 3: #information to draw Circle circle = Shapes.Circles(event.x(), event.y()) self.__shapes.append(circle) elif shapenum == 4: #information to draw Triangle tri = Shapes.Triangles(event.x(), event.y()) self.__shapes.append(tri) self.update()
def __init__(self, x, y, eqns): super(ExpressionList, self).__init__() self.setX(x) self.setY(y) self.tree = list(eqns) self.bg = Shapes.getDefaultBackBrush() self.fr = Shapes.getDefaultHighlightColor()
def runStartScreen(self): onStartScreen = True while onStartScreen: for event in pygame.event.get(): if event.type == pygame.QUIT: onStartScreen = False self.exit = True self.drawKinectFrame() self.getJointPos() drawStartText(self) if not drawDepthWarning(self) and playClicked(self): onStartScreen = False self.play = True elif editorClicked(self): onStartScreen = False self.editor = True Shapes.getHandCircle(self) Shapes.drawStartShapes(self) self.adjustKinectFrame() pygame.display.update() self.clock.tick(60)
def _calc_RMSD(x0, y, ppm, spins): x0 = np.ndarray.tolist(x0) ls = np.zeros_like(ppm) for i, s in enumerate(spins): s.set_opt_vals(x0) if i == 0: ls += Shapes.logistic_basline(ppm, s) else: ls += Shapes.Gaussian(ppm, s) return np.linalg.norm(y - ls)
def paint(self, painter, option, widget): pen = getDefaultExpressionPen() font = Shapes.getDefaultFont() brush = Shapes.getDefaultForeBrush() pen.setWidthF(2.0) painter.scale(1, -1) painter.setPen(pen) painter.setFont(font) painter.setBrush(brush) for i in self.tree: i.paint(painter, font, 0, 0);
def divide(self): self.divided = True cx = self.boundary.center.x cy = self.boundary.center.y w = self.boundary.w h = self.boundary.h ul_rect = Shapes.Rect(Shapes.Point(cx - w / 4., cy - h / 4.), w / 2., h / 2.) self.ul = QuadTree(ul_rect, self.capacity) ur_rect = Shapes.Rect(Shapes.Point(cx + w / 4., cy - h / 4.), w / 2., h / 2.) self.ur = QuadTree(ur_rect, self.capacity) ll_rect = Shapes.Rect(Shapes.Point(cx - w / 4., cy + h / 4.), w / 2., h / 2.) self.ll = QuadTree(ll_rect, self.capacity) lr_rect = Shapes.Rect(Shapes.Point(cx + w / 4., cy + h / 4.), w / 2., h / 2.) self.lr = QuadTree(lr_rect, self.capacity) for object in self.objects: self.ul.insert(object) self.ur.insert(object) self.ll.insert(object) self.lr.insert(object) self.objects = []
def print_dynamic(self, name, dyn, pos, alias, prop): def assert_pos(name, n): if len(pos) != n: raise Exception('%s dynamic expects %d offsets, provided %d' % (name, n, len(pos))) if dyn == 'force': assert_pos('force', 4) d = Shapes.Arrow(pos[0], pos[1], pos[2], pos[3], alias) elif dyn == 'weight': assert_pos('weight', 4) d = Shapes.Arrow(pos[0], pos[1], pos[2], pos[3], alias) elif dyn == 'rod': assert_pos('rod', 4) d = Shapes.Rod(pos[0], pos[1], pos[2], pos[3], alias) elif dyn == 'spring': assert_pos('spring', 4) d = Shapes.Spring(pos[0], pos[1], pos[2], pos[3], alias) elif dyn == 'dampener': assert_pos('dampener', 4) d = Shapes.Dampener(pos[0], pos[1], pos[2], pos[3], alias) elif dyn == 'torque': assert_pos('torque', 2) r = float(prop.get('radius', Shapes.getDefaultCArrowRadius())) c = prop.get('ccw', '0') if c == '0': c = False else: c = True d = Shapes.CircularArrow(pos[0], pos[1], r, alias) elif dyn == 'belt': assert_pos('belt', 4) c = prop.get('crossed', '0') r0 = float(prop['r0']) r1 = float(prop['r1']) if c == '0': c = False else: c = True d = Shapes.Belt(pos[0], pos[1], r0, pos[2], pos[3], r1, c, alias) elif dyn == 'angularspring': assert_pos('angularspring', 2) r = float(prop.get('radius', Shapes.getDefaultCArrowRadius())) d = Shapes.AngularSpring(pos[0], pos[1], r, alias) elif dyn == 'angulardampener': assert_pos('angulardampener', 2) r = float(prop.get('radius', Shapes.getDefaultCArrowRadius())) d = Shapes.AngularDampener(pos[0], pos[1], r, alias) else: raise Exception('unknown dynamic type %s' % dyn) self.dynscene[name] = d self.scene.addItem(d)
def __init__(self, handle): super(PeterActivity, self).__init__(handle) # Build the activity toolbar. toolbox = activity.ActivityToolbox(self) activity_toolbar = toolbox.get_activity_toolbar() activity_toolbar.keep.props.visible = False activity_toolbar.share.props.visible = False toolbox.show() self.set_toolbox(toolbox) # Create the game instance. self.game = Shapes.Shapes() # Build the Pygame canvas. self._pygamecanvas = \ sugargame.canvas.PygameCanvas(self) # Note that set_canvas implicitly calls # read_file when resuming from the Journal. self.set_canvas(self._pygamecanvas) self.game.canvas=self._pygamecanvas # Start the game running. self._pygamecanvas.run_pygame(self.game.run)
def test_example(): expected = 19.63495 circle = sh.Circle() circle.radius = 2.5 actual = round(circle.area, 5) print_test_results(test_example, expected, actual)
def __init__(self, resultsQueue): self.height = 24 self.width = 10 self.field = [ ] # Initialising the field with this for some reason breaks things [[0]*self.width]*self.height self.currentBlock = None self.score = 0 self.linesCleared = 0 self.level = 0 self.down = False self.gameOver = False self.reserved = None self.startX = (1920 / 2) - ( self.width * (35 / 2) ) #The top left of the grid's x cord, 35 is how big each square is in units self.startY = (1080 / 2) - ( self.height * (35 / 2) ) #The top left of the grid's y cord, 35 is how big each square is in units self.nextShapes = [] self.resultsQueue = resultsQueue for i in range(3): self.picked = self.nextShapes.append( Shapes.Shapes(3, 0, self.picked)) self.picked = self.nextShapes[-1].picked for i in range(self.height): newRow = [] for j in range(self.width): newRow.append(0) self.field.append(newRow)
def newBlock(self): self.down = False self.currentBlock = self.nextShapes.pop(0) self.nextShapes.append(Shapes.Shapes(3, 0, self.picked)) self.picked = self.nextShapes[-1].picked if self.intersects(): self.gameOver = True
def __init__(self, symbol): self.text = QtGui.QStaticText() self.text.setTextWidth(-1) opt = self.text.textOption() opt.setWrapMode(QtGui.QTextOption.NoWrap) self.text.setTextOption(opt) self.text.setText(Shapes.texToRTF(symbol))
def make_rect_at_center(x, y, w, h, rot=0): #pylint:disable-msg=C0103 """ Makes a collision rectangle. x, y specify the center of the rectangle. """ return Shapes.Rectangle(x, y, w, h, rot)
def make_rect_at_bottom_left(x, y, w, h, rot=0): #pylint:disable-msg=C0103 """ Makes a collision rectangle. x, y specify the bottom left corner of the rectangle. """ return Shapes.Rectangle(x + w / 2.0, y + w / 2.0, w, h, rot)
def redraw(self, type): if type == MOUSEMOTION and type != self.MODE: self.blit(Shapes.drawOutsetRect(self, self.get_size(), 10, Colors.LIGHT_BACKGROUND, Colors.MENU_BUTTON_BACKGROUND), (0,0)) self.blit(self.text, self.text_location) self.mainController.myView.MENU.drawMenu() self.mainController.myView.drawScreen() elif type == MOUSEBUTTONUP and type != self.MODE: self.blit(Shapes.drawOutsetRect(self, self.get_size(), 10, Colors.BACKGROUND, Colors.MENU_BUTTON_BACKGROUND), (0,0)) self.blit(self.text, self.text_location) self.mainController.myView.MENU.drawMenu() self.mainController.myView.drawScreen() elif type == MOUSEBUTTONDOWN and type != self.MODE: self.blit(Shapes.drawOutsetRect(self, self.get_size(), 10, Colors.DARK_GREY, Colors.MENU_BUTTON_BACKGROUND), (0,0)) self.blit(self.text, self.text_location) self.mainController.myView.MENU.drawMenu() self.mainController.myView.drawScreen()
def test_shapes_c(): shape_circle_test = Shapes.Circle() shape_circle_test.radius = 2.5 desc = "" expected = 19.63495 actual = shape_circle_test.area() print_test_results(test_shapes_c, desc, expected, actual) print str(shape_circle_test)
def test_find_circle_area(): '''Test radius 2.5''' expected = round(19.6349540849, 5) circle = sha.Circle() circle.radius = 2.5 actual = round(circle.area, 5) print_test_results(test_find_circle_area, expected, actual) print str(circle)
def test_circleArea(): circle1 = shp.Circle() circle1.radius = 2.5 expected = (math.pi * circle1.radius**2) desc = "Returns area of circle from radius." actual = circle1.area print_test_results(blank, desc, expected, actual) print str(circle1) , '\n'
def test_SquareArea(): square1 = shp.Square() square1.side_length = 3 expected = (square1.side_length ** 2) desc = "Returns area of square from side length." actual = square1.area print_test_results(blank, desc, expected, actual) print str(square1), '\n'
def test_find_square_area(): '''Test length 10''' expected = 9 square = sha.Square() square.length = 3 actual = square.area print_test_results(test_find_square_area, expected, actual) print str(square)
def test_shapes_s(): shape_square_test = Shapes.Square() shape_square_test.side = 2.0 desc = "" expected = 4.0 actual = shape_square_test.area() print_test_results(test_shapes_s, desc, expected, actual) print str(shape_square_test)
def draw_PENROSE(cr, tri, l): #Draws Penrose N-sided regular polygon onto canvas with a stroke and no fill #Checks if possible to draw with given polygon side length and offset length if 0 >= tri.side_length - 4 * l * (math.cos(tri.inter_angle) + 1): print "INVALID" return else: inner_tri = Shapes.RegPoly( tri.side_length - 4 * l * (math.cos(tri.inter_angle) + 1), tri.num_sides) inner_tri.set_center(tri.centerx, tri.centery) inner_tri.vertices(tri.offset) point_tri = [] for y in range(tri.num_sides): point_tri.append(Shapes.RegPoly(l, tri.num_sides)) point_tri[y].set_center(tri.centerx+(tri.radius-point_tri[y].radius)*math.cos(tri.angle*y \ +tri.offset),tri.centery+(tri.radius-point_tri[y].radius)*math.sin(tri.angle*y+tri.offset)) point_tri[y].vertices(tri.offset) #draw_RegPoly(cr,point_tri[y]) #draw_RegPoly(cr,tri) draw_RegPoly(cr, inner_tri) cr.move_to(point_tri[0].points[tri.num_sides - 1][0], point_tri[0].points[tri.num_sides - 1][1]) cr.line_to(point_tri[0].points[1][0], point_tri[0].points[1][1]) for x in range(1, tri.num_sides): a = (x + tri.num_sides - 1) % tri.num_sides b = (x + 1) % tri.num_sides cr.line_to(point_tri[x].points[a][0], point_tri[x].points[a][1]) cr.line_to(point_tri[x].points[b][0], point_tri[x].points[b][1]) cr.close_path() cr.stroke() for z in range(tri.num_sides): a = (z + tri.num_sides - 1) % tri.num_sides b = (z + 1) % tri.num_sides angle = tri.inter_angle*(float((tri.num_sides-3))/(tri.num_sides-2) ) - \ (tri.inter_angle)*(z)*(float(2)/(tri.num_sides-2)) cr.move_to(inner_tri.points[b][0], inner_tri.points[b][1]) cr.rel_line_to(l * math.sin(angle), l * math.cos(angle)) cr.line_to(point_tri[z].points[a][0], point_tri[z].points[a][1]) cr.stroke()
def test_square_area(): desc = 'Returns the the area of a square if we know the length of its side' square = Shapes.Square() side = 3 square.side = side expected = (side)**2 actual = square.area print_test_results(Shapes.Square, desc, expected, actual) print str(square) + '\n'
def test_find_rectangle_area(): '''Test length 2, width 4''' expected = 8 rectangle = sha.Rectangle() rectangle.length = 2 rectangle.width = 4 actual = rectangle.area print_test_results(test_find_rectangle_area, expected, actual) print str(rectangle)
def random_sphere(): r = random.random() g = random.random() b = random.random() x = random.randint(0, 10) * (random.random() * 2 - 1) y = random.randint(0, 10) * (random.random() * 2 - 1) z = random.randint(0, 10) * (random.random() * 2 - 1) sphere = Shapes.Sphere(1, 20, 20, (x, y, z), (r, g, b),(0, 0, 0)) return sphere
def Penrose(): Length, Width = 1000, 1000 for x in range(3, 10): img = cairo.SVGSurface("Penrose%s.svg" % x, Length, Width) cr = cairo.Context(img) polygon = Shapes.RegPoly(333, x) polygon.set_center(Length / 2, Width / 2) draw_PENROSE(cr, polygon, 30) cr.show_page()
def test_circle_area(): desc = 'Returns the the area of a circle if we know its radius' circle = Shapes.Circle() radius = 2.5 circle.radius = radius expected = math.pi * radius**2 actual = circle.area print_test_results(Shapes.Circle, desc, expected, actual) print str(circle) + '\n'
def listtopoints(points): Pts = [] for cs in points: try: x, y, z = cs Pts.append(Sh.Point(x, y, z)) except: Pts.append([]) return Pts
def test_RectangleArea(): rect1 = shp.Rectangle() rect1.width = 4 rect1.height = 2 expected = (rect1.height * rect1.width) desc = "Returns area of a rectangle from length and height." actual = rect1.area print_test_results(blank, desc, expected, actual) print str(rect1)
def test_shapes_r(): shape_rectangle_test = Shapes.Rectangle() shape_rectangle_test.height = 2.0 shape_rectangle_test.width = 4.0 desc = "" expected = 8.0 actual = shape_rectangle_test.area() print_test_results(test_shapes_r, desc, expected, actual) print str(shape_rectangle_test)
def boundingRect(self): h = 0 w = 0 m = getDefaultExpressionListMargin() font = Shapes.getDefaultFont() for eqn in self.tree: b = eqn.boundingRect(font) h += b.height() w = max(w, b.width()) return QtCore.QRectF(0, 0, w+m, h+m)
def _calc_RMSD( x0, y, ppm, spins ): x0 = np.ndarray.tolist(x0) ls = np.zeros_like(ppm) for i,s in enumerate(spins): s.set_opt_vals( x0 ) if i == 0: ls += Shapes.logistic_basline(ppm, s ) else: ls += Shapes.Gaussian(ppm, s) return np.linalg.norm( y - ls )
def sierpinski_sq_start(cr, sq, it): #Draws outer and center square of Sierpinski Carpet if it == 0: return draw_RegPoly(cr, sq) sq0 = Shapes.RegPoly(sq.side_length / 3, 4) sq0.set_center(sq.centerx, sq.centery) draw_RegPoly(cr, sq0) sierpinski_sq_rest(cr, sq0, it - 2)
def paint(self, painter, option, widget): pen = getDefaultExpressionPen() rpen = Shapes.getDefaultPen(True) font = Shapes.getDefaultFont() brush = Shapes.getDefaultForeBrush() m = getDefaultExpressionListMargin() b = self.boundingRect().adjusted(0, 0, m, m) pen.setWidthF(2.0) painter.scale(1, -1) painter.setPen(rpen) painter.setFont(font) painter.setBrush(self.bg) painter.drawRect(b) painter.setPen(pen) painter.setBrush(brush) h = m/2 for i in self.tree: b = i.boundingRect(font) i.paint(painter, font, -b.left() + m/2, h + b.height()/2); h += b.height()
def __init__(self, mainController, location, size, text, isDropdown, command, options=[], commands=[]): pygame.Surface.__init__(self, (size)) self.blit(Shapes.drawOutsetRect(self, size, 10, Colors.BACKGROUND, Colors.MENU_BUTTON_BACKGROUND), (0,0)) self.mainController = mainController self.size = size self.location = location self.text = text self.command = command self.isDropdown = isDropdown self.text = Sources.MENU_FONT.render(text, 1, Colors.MENU_BUTTON_TEXT_COLOR) self.text_location = (self.size[0]/2 - self.text.get_size()[0]/2, self.size[1]/2 - self.text.get_size()[1]/2) self.blit(self.text, self.text_location) self.MODE = MOUSEBUTTONUP
def __init__(self, mainController, location, size, text, command, insideColor, outsideColor): pygame.Surface.__init__(self, (size)) self.blit(Shapes.drawOutsetRect(self, size, 10, insideColor, outsideColor), (0,0)) self.insideColor = insideColor self.outsideColor = outsideColor self.mainController = mainController self.size = size self.location = location self.text = text self.command = command self.text = Sources.MENU_FONT.render(text, 1, Colors.MENU_BUTTON_TEXT_COLOR) self.text_location = (self.size[0]/2 - self.text.get_size()[0]/2, self.size[1]/2 - self.text.get_size()[1]/2) self.blit(self.text, self.text_location) self.MODE = MOUSEBUTTONUP
def coll_circle_line(circle, line, eps): """Circle-line collision detection.""" d = Shapes.vec(line.p2 - line.p1) #pylint:disable-msg=C0103 f = Shapes.vec(line.p1 - circle.get_center()) #pylint:disable-msg=C0103 a = d.dot(d) #pylint:disable-msg=C0103 b = 2 * f.dot(d) #pylint:disable-msg=C0103 c = f.dot(f) - (circle.radius * circle.radius + eps) #pylint:disable-msg=C0103,C0301 disc = b * b - 4 * a * c if disc < 0: #No intersection return False disc **= 0.5 t1 = (-b + disc) / (2 * a) #pylint:disable-msg=C0103 t2 = (-b - disc) / (2 * a) #pylint:disable-msg=C0103 if 0 <= t1 <= 1: return True if 0 <= t2 <= 1: return True return False
def __init__(self, location, size, text, hint, inputType, mainController): pygame.Surface.__init__(self, (size)) self.blit(Shapes.drawOutsetRect(self, size, 10, Colors.BACKGROUND, Colors.MENU_BUTTON_BACKGROUND), (0,0)) self.size = size self.location = location self.fillerText = text self.hint = hint self.text = text self.asciiText = [] self.text = Sources.MENU_FONT.render(text, 1, Colors.MENU_BUTTON_TEXT_COLOR) self.text_location = (self.size[0]/2 - self.text.get_size()[0]/2, self.size[1]/2 - self.text.get_size()[1]/2) self.blit(self.text, self.text_location) self.mainController = mainController self.MODE = MOUSEBUTTONUP self.ON_OFF_COUNTER = 0 self.HAS_FOCUS = False self.redraw(False)
def LorenDiff( ppm, y ): baseline = Sim.Spin.Spin( R1=y[-1], R2= 0, x0=0.0, c = 1.0 ) water = Sim.Spin.Spin( R1=0 , R2=100 , x0=0.0, c = 1e3 ) s1 = Sim.Spin.Spin( R1=0 , R2=1e4 , x0=-3.0, c = 1e3 ) baseline.set_lb_ub( 'c', None, None ) baseline.set_lb_ub( 'x0', None, None ) baseline.set_lb_ub( 'R1', None, None ) baseline.set_lb_ub( 'R2', None, None ) water.set_lb_ub( 'R2', None, None ) water.set_lb_ub( 'c', None, None ) water.set_lb_ub( 'x0', None, None ) s1.set_lb_ub( 'R2', None, None ) s1.set_lb_ub( 'c', None, None ) s1.set_lb_ub( 'x0', None, None ) spins = [baseline, water, s1] x0=[] for s in spins: for v in s.get_opt_vals(): x0.append(v) opt = optimize.minimize( _calc_RMSD, x0, args=(y, ppm, spins), method='Nelder-Mead', jac=False, options={'maxiter':1e4,'maxfev':1e4} ) ls = np.zeros_like(ppm) xxx = np.ndarray.tolist( opt.x ) for i,s in enumerate(spins): s.set_opt_vals( xxx ) if i == 0: ls += Shapes.logistic_basline(ppm, s ) else: ls += Shapes.Guassian(ppm, s ) return ls
def setUp(self): self.shapes = Shapes()
def getDefaultExpressionPen(): pen = Shapes.getDefaultPen() pen.setWidthF(1.0) return pen