Beispiel #1
0
 def transform_point(self, point, trafo=None):
     x = (point.x - self.minx) / self.width
     y = (point.y - self.miny) / self.height
     if trafo is None:
         trafo = self.get_random_trafo()
     start, end = self.splines[trafo[0]].GetDomain()
     length = end - start
     seg_length = length / self.num_trafos[trafo[0]]
     t = start + seg_length * trafo[1] + seg_length * x
     basepoint = self.splines[trafo[0]](t)
     if t + 1/50000 > end:
         neighbour = self.splines[trafo[0]](t - 1/50000)
         derivative = neighbour - basepoint
     else:
         neighbour = self.splines[trafo[0]](t + 1/50000)
         derivative = basepoint - neighbour
     if derivative.Mag() != 0:
         basepoint.x += derivative.y / derivative.Mag() * (y - 0.5) * \
                        self.thickness
         basepoint.y += -derivative.x / derivative.Mag() * (y - 0.5) * \
                        self.thickness
     else:
         print_("r", end='')
     self.truncate(basepoint)
     return basepoint
Beispiel #2
0
 def transform_point(self:Chaosgame, point:GVector, trafo=None)->GVector:
     x = (point.x - self.minx) / self.width
     y = (point.y - self.miny) / self.height
     if trafo is None:
         trafo = self.get_random_trafo()
     start, end = self.splines[trafo[0]].GetDomain()
     length = end - start
     seg_length = length / self.num_trafos[trafo[0]]
     t = start + seg_length * trafo[1] + seg_length * x
     basepoint = self.splines[trafo[0]](t)
     if t + 1/50000 > end:
         neighbour = self.splines[trafo[0]](t - 1/50000)
         derivative = neighbour - basepoint
     else:
         neighbour = self.splines[trafo[0]](t + 1/50000)
         derivative = basepoint - neighbour
     if derivative.Mag() != 0:
         basepoint.x += derivative.y / derivative.Mag() * (y - 0.5) * \
                        self.thickness
         basepoint.y += -derivative.x / derivative.Mag() * (y - 0.5) * \
                        self.thickness
     else:
         print_("r", end='')
     self.truncate(basepoint)
     return basepoint
Beispiel #3
0
def trace(a):
    global layout
    layout -= 1
    if layout <= 0:
        print_()
        layout = 50
    print_(a, end='')
def trace(a):
    global layout
    layout -= 1
    if layout <= 0:
        print_()
        layout = 50
    print_(a, end='')
Beispiel #5
0
def main(entry_point = entry_point, iterations = 10)->int:
    print_("Richards benchmark (Python) starting... [%r]" % entry_point)
    result, startTime, endTime = entry_point(iterations)
    if not result:
        print_("Incorrect results!")
        return -1
    print_("finished.")
    total_s = endTime - startTime
    print_("Total time for %d iterations: %.2f secs" %(iterations,total_s))
    print_("Average time per iteration: %.2f ms" %(total_s*1000/iterations))
    return 42
def main(entry_point=entry_point, iterations=10):
    print_("Richards benchmark (Python) starting... [%r]" % entry_point)
    result, startTime, endTime = entry_point(iterations)
    if not result:
        print_("Incorrect results!")
        return -1
    print_("finished.")
    total_s = endTime - startTime
    print_("Total time for %d iterations: %.2f secs" % (iterations, total_s))
    print_("Average time per iteration: %.2f ms" %
           (total_s * 1000 / iterations))
    return 42
Beispiel #7
0
def schedule():
    t = taskWorkArea.taskList
    while t is not None:
        pkt = None

        if tracing:
            print_("tcb =",t.ident)

        if t.isTaskHoldingOrWaiting():
            t = t.link
        else:
            if tracing: trace(chr(ord("0")+t.ident))
            t = t.runTask()
def schedule():
    t = taskWorkArea.taskList
    while t is not None:
        pkt = None

        if tracing:
            print_("tcb =", t.ident)

        if t.isTaskHoldingOrWaiting():
            t = t.link
        else:
            if tracing: trace(chr(ord("0") + t.ident))
            t = t.runTask()
 def transform_point(self, point, trafo=None):
     x = ((check3(point).x - check11(self).minx) / check12(self).width)
     y = ((check4(point).y - check9(self).miny) / check13(self).height)
     if (trafo is None):
         trafo = check_type_function(check20(self).get_random_trafo)()
     (start, end) = check_type_tuple(check_type_function(check22(check21(self).splines[trafo[0]]).GetDomain)(), 2)
     length = (end - start)
     seg_length = (length / check15(self).num_trafos[trafo[0]])
     t = ((start + (seg_length * trafo[1])) + (seg_length * x))
     basepoint = check_type_function(check21(self).splines[trafo[0]])(t)
     if ((t + (1 / 50000)) > end):
         neighbour = check_type_function(check21(self).splines[trafo[0]])((t - (1 / 50000)))
         derivative = (neighbour - basepoint)
     else:
         neighbour = check_type_function(check21(self).splines[trafo[0]])((t + (1 / 50000)))
         derivative = (basepoint - neighbour)
     if (check_type_function(check23(derivative).Mag)() != 0):
         basepoint.x = (check3(basepoint).x + (((check4(derivative).y / check_type_function(check23(derivative).Mag)()) * (y - 0.5)) * check24(self).thickness))
         basepoint.y = (check4(basepoint).y + ((((- check3(derivative).x) / check_type_function(check23(derivative).Mag)()) * (y - 0.5)) * check24(self).thickness))
     else:
         print_('r', end='')
     check_type_function(check25(self).truncate)(basepoint)
     return check1(basepoint)
Beispiel #10
0
def run_benchmark(options, num_runs, bench_func, *args):
    """Run the given benchmark, print results to stdout.

    Args:
        options: optparse.Values instance.
        num_runs: number of times to run the benchmark
        bench_func: benchmark function. `num_runs, *args` will be passed to this
            function. This should return a list of floats (benchmark execution
            times).
    """
    timer = getattr(time, options.timer)
    if options.profile:
        import cProfile
        prof = cProfile.Profile()
        prof.runcall(bench_func, num_runs, timer, *args)
        prof.print_stats(sort=options.profile_sort)
    else:
        data = bench_func(num_runs, timer, *args)
        if options.take_geo_mean:
            product = reduce(operator.mul, data, 1)
            print_(math.pow(product, 1.0 / len(data)))
        else:
            for x in data:
                print_(x)
Beispiel #11
0
def run_benchmark(options, num_runs, bench_func, *args):
    """Run the given benchmark, print results to stdout.

    Args:
        options: optparse.Values instance.
        num_runs: number of times to run the benchmark
        bench_func: benchmark function. `num_runs, *args` will be passed to this
            function. This should return a list of floats (benchmark execution
            times).
    """
    timer = getattr(time, options.timer)
    if options.profile:
        import cProfile
        prof = cProfile.Profile()
        prof.runcall(bench_func, num_runs, timer, *args)
        prof.print_stats(sort=options.profile_sort)
    else:
        data = bench_func(num_runs, timer, *args)
        if options.take_geo_mean:
            product = reduce(operator.mul, data, 1)
            print_(math.pow(product, 1.0 / len(data)))
        else:
            for x in data:
                print_(x)