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


Python circle.Circle类代码示例

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


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

示例1: fcp_start

def fcp_start():
    global circle, fcp, treewalk

    workq = None  # if fresh start, workq is None

    if not args.rid: # if not in recovery
        treewalk = FWalk(circle, G.src, G.dest, force=args.force)
        circle.begin(treewalk)
        circle.finalize()
        G.totalsize = treewalk.epilogue()
    else:  # okay, let's do checkpoint recovery
        workq = prep_recovery()

    circle = Circle()
    fcp = FCP(circle, G.src, G.dest,
              treewalk=treewalk,
              totalsize=G.totalsize,
              verify=args.verify,
              workq=workq,
              hostcnt=num_of_hosts)

    if comm.rank == 0 and G.verbosity > 0:
        rcl, wcl = fcp.rw_cache_limit()
        print("")
        print("\t{:<25}{:<10}{:5}{:<25}{:<10}".format("Read Cache:", "%s" % rcl, "|",
                                                      "Write Cache:", "%s" % wcl))
        print("")
    set_chunksize(fcp, G.totalsize)
    fcp.checkpoint_interval = args.cptime
    fcp.checkpoint_file = ".pcp_workq.%s.%s" % (args.cpid, circle.rank)

    circle.begin(fcp)
    circle.finalize()
    fcp.cleanup()
开发者ID:verolero86,项目名称:pcircle,代码行数:34,代码来源:fcp.py

示例2: MyGroup

class MyGroup(Group):
    """Represents a group on the floor.

    Create a group as a subclass of the basic data element.

    Stores the following values:
        m_color: color of cell

    """

    def __init__(self, field, id, gsize=None, duration=None, x=None, y=None,
                 diam=None, color=None):
        if color is None:
            self.m_color = DEF_GROUPCOLOR
        else:
            self.m_color = color
        self.m_shape = Circle()
        super(MyGroup, self).__init__(field, id, gsize, duration, x, y, diam)

    def update(self, gsize=None, duration=None, x=None, y=None,
                 diam=None, color=None):
        """Store basic info and create a DataElement object"""
        if color is not None:
            self.m_color = color
        super(MyGroup, self).update(gsize, duration, x, y, diam)

    def draw(self):
        if self.m_x is not None and self.m_y is not None:
            self.m_shape.update(self.m_field, (self.m_x, self.m_y),
                                self.m_diam/2, self.m_color, solid=False)
            self.m_shape.draw()
开发者ID:btownshend,项目名称:crs,代码行数:31,代码来源:mygroup.py

示例3: fcp_start

def fcp_start():
    global circle, fcp, treewalk

    workq = None  # if fresh start, workq is None

    if not args.rid: # if not in recovery
        treewalk = FWalk(circle, G.src, G.dest, force=args.force)
        circle.begin(treewalk)
        circle.finalize()
        treewalk.epilogue()
    else:  # okay, let's do checkpoint recovery
        workq = prep_recovery()

    circle = Circle(dbname="fcp")
    fcp = FCP(circle, G.src, G.dest,
              treewalk=treewalk,
              totalsize=T.total_filesize,
              verify=args.verify,
              workq=workq,
              hostcnt=num_of_hosts)

    set_chunksize(fcp, T.total_filesize)
    fcp.checkpoint_interval = args.cptime
    fcp.checkpoint_file = ".pcp_workq.%s.%s" % (args.cpid, circle.rank)

    circle.begin(fcp)
    circle.finalize()
    fcp.epilogue()
开发者ID:fwang2,项目名称:pcircle,代码行数:28,代码来源:fcp.py

示例4: __init__

	def __init__(self):
		position = Point(random.randint(0,config.SCREEN_X),random.randint(0,config.SCREEN_Y))
		radius = config.STAR_RADIUS
		rotation = 0
		random_color = random.randint(0, 255)
		color = (random_color, random_color , random_color)
		Circle.__init__(self, position, radius, color, rotation)
开发者ID:majormoses,项目名称:asteroids,代码行数:7,代码来源:stars.py

示例5: test_set_area

def test_set_area():
    c = Circle(4)
    try:
        c.area = 10
    except AttributeError as error:
        assert error.message == "can't set attribute"
    else:
        assert False
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:8,代码来源:circle_test.py

示例6: __init__

class Controller:
    def __init__(self):
        self.circle = Circle(width/2, height/2, 100)
    def draw(self):
        background(0, 0, 0)
	stroke(50, 50, 200) # set stroke color bluish
        self.circle.draw()
        self.circle.move(0.25,0.25)
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:8,代码来源:example2-controller.py

示例7: test_change_diameter

def test_change_diameter():
    c = Circle(2)

    assert c.radius == 2
    assert c.diameter == 4

    c.diameter = 6
    assert c.radius == 3
    assert c.diameter == 6
开发者ID:DZwell,项目名称:sea-c34-python,代码行数:9,代码来源:test_circle2.py

示例8: main

def main():
    global comm, args
    args = parse_and_bcast(comm, gen_parser)

    try:
        G.src = utils.check_src(args.path)
    except ValueError as e:
        err_and_exit("Error: %s not accessible" % e)

    G.use_store = args.use_store
    G.loglevel = args.loglevel

    hosts_cnt = tally_hosts()

    if comm.rank == 0:
        print("Running Parameters:\n")
        print("\t{:<20}{:<20}".format("FWALK version:", __version__))
        print("\t{:<20}{:<20}".format("Num of hosts:", hosts_cnt))
        print("\t{:<20}{:<20}".format("Num of processes:", MPI.COMM_WORLD.Get_size()))
        print("\t{:<20}{:<20}".format("Root path:", utils.choplist(G.src)))

    circle = Circle()
    treewalk = FWalk(circle, G.src)
    circle.begin(treewalk)

    if G.use_store:
        treewalk.flushdb()

    if args.stats:
        hist = global_histogram(treewalk)
        total = hist.sum()
        bucket_scale = 0.5
        if comm.rank == 0:
            print("\nFileset histograms:\n")
            for idx, rightbound in enumerate(bins[1:]):
                percent = 100 * hist[idx] / float(total)
                star_count = int(bucket_scale * percent)
                print("\t{:<3}{:<15}{:<8}{:<8}{:<50}".format("< ",
                    utils.bytes_fmt(rightbound), hist[idx],
                    "%0.2f%%" % percent, '∎' * star_count))

    if args.stats:
        treewalk.flist.sort(lambda f1, f2: cmp(f1.st_size, f2.st_size), reverse=True)
        globaltops = comm.gather(treewalk.flist[:args.top])
        if comm.rank == 0:
            globaltops = [item for sublist in globaltops for item in sublist]
            globaltops.sort(lambda f1, f2: cmp(f1.st_size, f2.st_size), reverse=True)
            if len(globaltops) < args.top:
                args.top = len(globaltops)
            print("\nStats, top %s files\n" % args.top)
            for i in xrange(args.top):
                print("\t{:15}{:<30}".format(utils.bytes_fmt(globaltops[i].st_size),
                      globaltops[i].path))

    treewalk.epilogue()
    treewalk.cleanup()
    circle.finalize()
开发者ID:verolero86,项目名称:pcircle,代码行数:57,代码来源:fwalk.py

示例9: test_area2

def test_area2():
	"""
	area should change if radius changes 
	"""
	c = Circle(4)

	c.radius = 2

	assert c.get_area() == math.pi * 4
开发者ID:harlanaubuchon,项目名称:IntroToPython,代码行数:9,代码来源:test_circle.py

示例10: initial_trilateration

def initial_trilateration(p0, p1, distance_matrix):
    points = [p0, p1]
    for target_number in range(2, distance_matrix.shape[0]):
        d0t = distance_matrix[0][target_number]
        c0t = Circle(p0, d0t)
        d1t = distance_matrix[1][target_number]
        c1t = Circle(p1, d1t)
        points.append(c0t.positive_intersection_with(c1t))
    return points
开发者ID:jgowans,项目名称:array-element-coordinate-calculator,代码行数:9,代码来源:array_trilateration.py

示例11: define

    def define (self, dwg):

        for element in range(0,1000):
            circle = Circle()
            line = Line()
            parabola = Parabola()
            splash = Splash()
            circle.define(dwg)
            line.define(dwg)
            parabola.define(dwg)
            splash.define(dwg)
开发者ID:MatiPruvost,项目名称:pyllock,代码行数:11,代码来源:canvas.py

示例12: __init__

 def __init__(self, field, id, x=None, y=None, vx=None, vy=None, major=None,
              minor=None, gid=None, gsize=None, color=None):
     if color is None:
         self.m_color = DEF_LINECOLOR
     else:
         self.m_color = color
     self.m_body_color = DEF_BODYCOLOR
     self.m_shape = Circle()
     self.m_bodyshape = Circle()
     super(MyCell, self).__init__(field, id, x, y, vx, vy, major, minor,
                                  gid, gsize)
开发者ID:btownshend,项目名称:crs,代码行数:11,代码来源:mycell.py

示例13: test_circle_distance_from_frame

 def test_circle_distance_from_frame(self):
     '''
     Test overlap between circles and frame.
     '''
     new_circle = Circle(20)
     new_circle.set_position(160, 160)
     self.assertAlmostEqual(200 - math.sqrt(2)*20 - 20,
                            new_circle.get_distance_from_frame(200), 2) 
     new_circle.set_position(420, 180)
     self.assertAlmostEqual(-60, new_circle.get_distance_from_frame(200), 2)
     new_circle.set_position(180 + 1 / math.sqrt(2) * 180, 
                             180 + 1 / math.sqrt(2) * 180)
     self.assertAlmostEqual(0, new_circle.get_distance_from_frame(200), 2)
开发者ID:msimberg,项目名称:packman,代码行数:13,代码来源:shapetest.py

示例14: test_nonsense_diameter

def test_nonsense_diameter():
    """
    Make sure we can't create a Circle object with a negative or zero 
    diameter.
    """
    with pytest.raises(ValueError):
        c = Circle.from_diameter(-2.468)
    with pytest.raises(ValueError):
        c = Circle.from_diameter(0)
    c = Circle.from_diameter(2.468)
    with pytest.raises(ValueError):
        c.diameter = -2.468
    with pytest.raises(ValueError):
        c.diameter = 0
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:14,代码来源:test_circle.py

示例15: test_nonsense_radius

def test_nonsense_radius():
    """
    Make sure we can't create a Circle object with a negative or zero 
    radius.
    """
    with pytest.raises(ValueError):
        c = Circle(-1.234)
    with pytest.raises(ValueError):
        c = Circle(0)
    c = Circle(1.234)
    with pytest.raises(ValueError):
        c.radius = -1.234 
    with pytest.raises(ValueError):
        c.radius = 0
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:14,代码来源:test_circle.py


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