コード例 #1
0
def install():
    version = get_config_value(lvl, 'java')

    ans = ''
    if silent_mode == 'silent':
        ans = 'y'
    else:
        ans = get_input('Do you want to install/update ' + version +
                        ' ? [y/n] ')

    while ans != 'y' and ans != 'n':
        ans = get_input('Do you want to install/update ' + version +
                        ' ? [y/n] ')
    if (ans == 'n'):
        print('Skipping Java installation.')
        print('Exiting...')
        exit()
    check_java = 'rpm -q java-1.8.0-openjdk-devel.x86_64 > /dev/null'
    result = subprocess.call(check_java, shell='True')
    if result != 0:
        print('Attempting ' + version + ' installation...')
        sleep(2)
        result = subprocess.call('sudo yum -y install ' + version,
                                 shell='True')
        if result == 0:
            print('Installation successful!')
    else:
        print('The required version of java is already installed.')
        print('Exiting...')
コード例 #2
0
ファイル: day1.py プロジェクト: dmcnavish/adventOfCode
def main():
    captcha = get_input('../input/day1.in')[0]
    dups = find_dups(captcha)
    print "part 1 total: " + str(sum(dups))

    captcha = get_input('../input/day1-part2.in')[0]
    dups = find_half_dups(captcha)
    print "part 2 total: " + str(sum(dups))
コード例 #3
0
 def test_large_motor(self):
     get_input("Attach a LargeMotor then continue")
     d = LargeMotor()
     print(d.driver_name)
     d.run_forever(100, speed_regulation=False)
     print(d.state)
     time.sleep(5)
     d.stop()
コード例 #4
0
 def test_medium_motor(self):
     get_input('Attach a MediumMotor then continue')
     d = MediumMotor()
     print(d.type)
     d.run_forever(100, regulation_mode=False)
     print(d.run)
     time.sleep(5)
     d.stop()
コード例 #5
0
 def test_medium_motor(self):
     get_input('Attach a MediumMotor then continue')
     d = MediumMotor()
     print(d.driver_name)
     d.run_forever(100, speed_regulation=False)
     print(d.state)
     time.sleep(5)
     d.stop()
コード例 #6
0
 def test_PSPNxV4(self):
     get_input('Attach a PSPNxV4 at port 3 then continue')    	
     d = PSPNxV4(3)
     print(d.version)
     print(d.vendor_id)
     print(d.device_id)
     get_input('test button_set_1')
     print(d.button_set_1)
コード例 #7
0
 def test_tone(self):
     get_input('Test beep')
     d= Tone()
     d.play(1000, 3000)
     time.sleep(3)
     d.play(1000)
     time.sleep(3)
     d.stop()
コード例 #8
0
 def test_medium_motor(self):
     get_input('Attach a MediumMotor then continue')
     d = MediumMotor()
     print(d.driver_name)
     d.run_forever(100, speed_regulation=False)
     print(d.state)
     time.sleep(5)
     d.stop()
コード例 #9
0
 def test_medium_motor(self):
     get_input('Attach a MediumMotor then continue')
     d = MediumMotor()
     print(d.type)
     d.run_forever(100, regulation_mode=False)
     print(d.run)
     time.sleep(5)
     d.stop()
コード例 #10
0
ファイル: test_ev3_tone.py プロジェクト: dzxx301/mywebs
 def test_tone(self):
     get_input('Test beep')
     d = Tone()
     d.play(1000, 3000)
     time.sleep(3)
     d.play(1000)
     time.sleep(3)
     d.stop()
コード例 #11
0
    def test_medium_motor(self):
        get_input('Attach a MediumMotor then continue')
        d = MediumMotor()
        print(d.type)
        #d.run_forever(25, regulation_mode=False)
	d.run_time_limited(time_sp=5000, speed_sp=25, regulation_mode=False,
                           stop_mode=Motor.STOP_MODE.COAST, ramp_up_sp=100, ramp_down_sp=100)
        print(d.run)
        time.sleep(5)
        d.stop()
コード例 #12
0
 def test_msensor(self):
     get_input('Attach a Msensor on port 1 then continue')
     d = Msensor(port=1)
     print(d.mode)
     type_id = d.type_id
     print(type_id)
     print(d.port)
     d = Msensor(type_id=type_id)
     print(d.mode)
     print(d.type_id)
     print(d.port)
コード例 #13
0
 def test_LegoSensor(self):
     get_input('Attach a Msensor on port 1 then continue')
     d = LegoSensor(port=1)
     print(d.mode)
     print(d.port)
     if (len(glob.glob('/sys/class/lego-sensor/sensor*/name')) >0):
         name = d.name
         print(name)
         d = LegoSensor(name=name)
     print(d.mode)
     print(d.port)
コード例 #14
0
 def test_LegoSensor(self):
     get_input('Attach a Msensor on port 1 then continue')
     d = LegoSensor(port=1)
     print(d.mode)
     print(d.port)
     if (len(glob.glob('/sys/class/lego-sensor/sensor*/name')) > 0):
         name = d.name
         print(name)
         d = LegoSensor(name=name)
     print(d.mode)
     print(d.port)
コード例 #15
0
ファイル: test_ev3_lcd.py プロジェクト: improper4/python-ev3
 def test_lcd(self):
     get_input('Test lcd')
     d= Lcd()        
     d.draw.ellipse((20, 20, 60, 60))
     d.update()
     time.sleep(2)
     d.reset()
     font = ImageFont.load_default() 
     d.draw.text((10, 10), "hello", font=font)
     d.update()
     time.sleep(2)
     d.reset()
     font = ImageFont.truetype('/usr/share/fonts/truetype/arphic/uming.ttc',15)
     d.draw.text((20, 20), u'你好,世界', font=font)
     d.update()
コード例 #16
0
 def test_color_sensor(self):
     get_input('Attach a ColorSensor then continue')
     d = ColorSensor()
     get_input('test rgb')
     print(d.rgb)
     print(d.mode)
     get_input('test color')
     print(d.color)
     print(d.mode)
     get_input('test reflect')
     print(d.reflect)
     print(d.mode)
     get_input('test ambient')
     print(d.ambient)
     print(d.mode)
コード例 #17
0
def main():
    spreadsheet = get_input('../input/day2.in')

    differences = []
    for row in spreadsheet:
        differences.append(find_difference(row))

    print "checksum: " + str(sum(differences))

    spreadsheet = get_input('../input/day2-part2.in')
    divisions = []
    for row in spreadsheet:
        divisions.append(find_divisible_difference(row))

    print "divisions sum: " + str(sum(divisions))
コード例 #18
0
 def test_msensor(self):
     get_input('Attach a Msensor on port 1 then continue')
     d = Msensor(port=1)
     print(d.mode)
     print(d.port)
     if (len(glob.glob('/sys/class/msensor/sensor*/type_id')) > 0):
         type_id = d.type_id
         print(type_id)
         d = Msensor(type_id=type_id)
     if (len(glob.glob('/sys/class/msensor/sensor*/name')) > 0):
         name = d.name
         print(name)
         d = Msensor(name=name)
     print(d.mode)
     print(d.port)
コード例 #19
0
ファイル: test_ev3_lcd.py プロジェクト: jdieter/python-ev3
 def test_lcd(self):
     get_input("Test lcd")
     d = Lcd()
     d.draw.ellipse((20, 20, 60, 60))
     d.update()
     time.sleep(2)
     d.reset()
     font = ImageFont.load_default()
     d.draw.text((10, 10), "hello", font=font)
     try:
         font = ImageFont.truetype("/usr/share/fonts/truetype/arphic/uming.ttc", 15)
         d.draw.text((20, 20), u"你好,世界", font=font)
     except IOError:
         print("No uming.ttc found. Skip the CJK test")
     d.update()
コード例 #20
0
 def test_msensor(self):
     get_input('Attach a Msensor on port 1 then continue')
     d = Msensor(port=1)
     print(d.mode)
     print(d.port)
     if (len(glob.glob('/sys/class/msensor/sensor*/type_id')) >0):
         type_id = d.type_id
         print(type_id)
         d = Msensor(type_id=type_id)
     if (len(glob.glob('/sys/class/msensor/sensor*/name')) >0):
         name = d.name
         print(name)
         d = Msensor(name=name)
     print(d.mode)
     print(d.port)
コード例 #21
0
 def test_color_sensor(self):
     get_input('Attach a ColorSensor then continue')
     d = ColorSensor()
     get_input('test rgb')
     print(d.rgb)
     print(d.mode)
     get_input('test color')
     print(d.colors[d.color])
     print(d.mode)
     get_input('test reflect')
     print(d.reflect)
     print(d.mode)
     get_input('test ambient')
     print(d.ambient)
     print(d.mode)
コード例 #22
0
ファイル: taskwiki.py プロジェクト: akashin/taskwiki
    def modify(self, modstring):
        # If no modstring was passed as argument, ask the user interactively
        if not modstring:
            with util.current_line_highlighted():
                modstring = util.get_input("Enter modifications: ")

        # We might have two same tasks in the range, make sure we do not pass the
        # same uuid twice
        unique_tasks = set(vimwikitask.task['uuid'] for vimwikitask in self.tasks)
        uuids = list(unique_tasks)

        # Generate the arguments from the modstring
        args = util.tw_modstring_to_args(modstring)

        # Modify all tasks at once
        output = util.tw_execute_safely(self.tw, uuids + ['mod'] + args)

        # Update the touched tasks in buffer, if needed
        cache.load_tasks()
        cache.update_vwtasks_from_tasks()
        cache.update_vwtasks_in_buffer()

        # Output the feedback from TW
        if output:
            print(output[-1])

        cache.buffer.push()
コード例 #23
0
    def initialize(self):
        version = util.get_input('Enter Zoom version [2/3]: ')
        util.Msg('Changing admin password to \'d3fault\'...')

        url_25 = 'http://%s/hag/emweb/PopOutUserModify.htm/FormOne&user=admin&'\
                 'ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&id=3&'\
                 'cmdSubmit=Save+Changes' % self.config['target'].value
        url_30 = 'http://%s/hag/emweb/PopOutUserModify.htm?id=40&user=admin&'\
                 'Zadv=1&ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&'\
                 'id=3&cmdSubmit=Save+Changes' % self.config['target'].value
        url_logs = 'http://%s/Action?id=76&cmdClear+Log=Clear+Log' % self.config[
            'target'].value

        try:
            if version == '2':
                urllib.urlopen(url_25).read()
            else:
                urllib.urlopen(url_30).read()

            util.Msg("Password reset, clearing logs...")
            urllib.urlopen(url_logs).read()
            util.Msg('Done.  Connect to %s with admin:d3fault' %
                     self.config['target'].value)
        except Exception, e:
            util.Error('Unable to connect: %s' % e)
コード例 #24
0
ファイル: day06.py プロジェクト: cescara/aoc2019
def main():
    with open(get_input(__file__)) as file:
        orbits = read_input(file)

    print(part1(orbits))
    Node.nodes = {}
    print(part2(orbits))
コード例 #25
0
 def test_lcd(self):
     get_input('Test lcd')
     d = Lcd()
     d.draw.ellipse((20, 20, 60, 60))
     d.update()
     time.sleep(2)
     d.reset()
     font = ImageFont.load_default()
     d.draw.text((10, 10), "hello", font=font)
     try:
         font = ImageFont.truetype(
             '/usr/share/fonts/truetype/arphic/uming.ttc', 15)
         d.draw.text((20, 20), u'你好,世界', font=font)
     except IOError:
         print('No uming.ttc found. Skip the CJK test')
     d.update()
コード例 #26
0
ファイル: x4_5_mod_password.py プロジェクト: NullMode/zarp
    def run(self):
        version = util.get_input("Enter Zoom version [2/3]: ")
        util.Msg("Changing admin password to 'd3fault'...")

        url_25 = (
            "http://%s/hag/emweb/PopOutUserModify.htm/FormOne&user=admin&"
            "ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&id=3&"
            "cmdSubmit=Save+Changes" % self.ip
        )
        url_30 = (
            "http://%s/hag/emweb/PopOutUserModify.htm?id=40&user=admin&"
            "Zadv=1&ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&"
            "id=3&cmdSubmit=Save+Changes" % self.ip
        )
        url_logs = "http://%s/Action?id=76&cmdClear+Log=Clear+Log" % self.ip

        try:
            if version == "2":
                urllib.urlopen(url_25).read()
            else:
                urllib.urlopen(url_30).read()

            util.Msg("Password reset, clearing logs...")
            urllib.urlopen(url_logs).read()
            util.Msg("Done.  Connect to %s with admin:d3fault" % self.ip)
        except Exception, e:
            util.Error("Unable to connect: %s" % e)
コード例 #27
0
 def test_infrared_sensor(self):
     get_input('Attach a InfraredSensor then continue')
     d= InfraredSensor()
     print(d.mode)
     get_input('test proxy')
     print(d.prox)
     print(d.mode)
     get_input('test remote')
     print(d.remote)
     print(d.mode)
     get_input('test remote_bin')
     print(d.remote_bin)
     print(d.mode)
     get_input('test seek')
     print(d.seek)
     print(d.mode)
コード例 #28
0
 def test_infrared_sensor(self):
     get_input('Attach a InfraredSensor then continue')
     d = InfraredSensor()
     print(d.mode)
     get_input('test proximity')
     print(d.prox)
     print(d.mode)
     get_input('test remote')
     print(d.remote)
     print(d.mode)
     get_input('test remote_bin')
     print(d.remote_bin)
     print(d.mode)
     get_input('test seek')
     print(d.seek)
     print(d.mode)
コード例 #29
0
ファイル: taskwiki.py プロジェクト: lubcik/taskwiki
    def modify(self, modstring):
        # If no modstring was passed as argument, ask the user interactively
        if not modstring:
            with util.current_line_highlighted():
                modstring = util.get_input("Enter modifications: ")

        # We might have two same tasks in the range, make sure we do not pass the
        # same uuid twice
        unique_tasks = set(vimwikitask.task['uuid'] for vimwikitask in self.tasks)
        uuids = list(unique_tasks)

        # Generate the arguments from the modstring
        args = util.tw_modstring_to_args(modstring)

        # Modify all tasks at once
        output = util.tw_execute_safely(self.tw, uuids + ['mod'] + args)

        # Update the touched tasks in buffer, if needed
        cache.load_tasks()
        cache.update_vwtasks_from_tasks()
        cache.update_vwtasks_in_buffer()

        # Output the feedback from TW
        if output:
            print(output[-1])
コード例 #30
0
ファイル: taskwiki.py プロジェクト: akashin/taskwiki
    def annotate(self, annotation):
        if not annotation:
            with util.current_line_highlighted():
                annotation = util.get_input("Enter annotation: ")

        for vimwikitask in self.tasks:
            vimwikitask.task.add_annotation(annotation)
            print("Task \"{0}\" annotated.".format(vimwikitask['description']))
コード例 #31
0
def main():
    input_data = get_input('../input/day6.in')
    parsed_data = map(int, parse_row(input_data[0]))
    count, dup = infinite_loop(parsed_data)
    print "part1 count: " + str(count)

    refind_count = find_again(dup[:], dup)
    print "refind_count: " + str(refind_count)
コード例 #32
0
 def __init__(self, day):
     self.day = day
     self.program_initial = make_program(get_input(day, split=True))
     self.program = self.program_initial.copy()
     self.ip = 0
     self.rb = 0
     self.output_buffer = []
     self.finished = False
コード例 #33
0
ファイル: taskwiki.py プロジェクト: lubcik/taskwiki
    def annotate(self, annotation):
        if not annotation:
            with util.current_line_highlighted():
                annotation = util.get_input("Enter annotation: ")

        for vimwikitask in self.tasks:
            vimwikitask.task.add_annotation(annotation)
            print("Task \"{0}\" annotated.".format(vimwikitask['description']))
コード例 #34
0
def product_of_sum():
    expense_reports = get_input('./input')
    for i, val_1 in enumerate(expense_reports):
        for j, val_2 in enumerate(expense_reports[i + 1:]):
            for val_3 in expense_reports[j + i + 2:]:
                if val_1 + val_2 + val_3 == 2020:
                    print(val_1, val_2, val_3, val_1 * val_2 * val_3)
                    return
コード例 #35
0
 def test_groups_as_lists(self):
     test_input = get_input('test_input.txt')
     retrieved_groups = list(groups_as_lists(test_input))
     self.assertTrue(len(retrieved_groups), 5)
     self.assertEqual(retrieved_groups[0], ['abc'])
     self.assertEqual(retrieved_groups[1], ['a', 'b', 'c'])
     self.assertEqual(retrieved_groups[2], ['ab', 'ac'])
     self.assertEqual(retrieved_groups[3], ['a', 'a', 'a', 'a'])
     self.assertEqual(retrieved_groups[4], ['b'])
コード例 #36
0
def checksum():
	content = get_input('day02.txt')
	two = 0
	three = 0
	for line in content:
		counts = [line.count(l) for l in set(line.strip())]
		two += 1 if 2 in counts else 0
		three += 1 if 3 in counts else 0
	return two * three
コード例 #37
0
ファイル: day7.py プロジェクト: dmcnavish/adventOfCode
def main():
    all_input = get_input('../input/day7.in')
    all_programs = parse_input(all_input)
    top_parent = find_top_parent(all_programs)
    print "part1 top parent: " + str(top_parent)

    tree = build_tree(all_programs)
    top_program = find_program(tree, top_parent)
    print_holding_weights(top_program)
コード例 #38
0
ファイル: day5.py プロジェクト: a-recknagel/AOC2019
def part_1():
    test_1_1 = IntCode([1002, 4, 3, 4, 33], [1]).run()
    print(f"{test_1_1=}")
    test_1_2 = IntCode([3, 0, 4, 0, 99], [1]).run()
    print(f"{test_1_2=}")

    data = list(map(int, get_input("data/day5")[0].split(',')))
    res_1 = IntCode(data, [1]).run()
    print(f"{res_1=}")
コード例 #39
0
def main():
    with open(get_input(__file__)) as file:
        pw_range = list(map(int, file.read().strip().split("-")))

    candidates_part1 = [password for password in range(pw_range[0], pw_range[1]) if part1(str(password))]
    print(len(candidates_part1))

    candidates_part2 = [password for password in range(pw_range[0], pw_range[1]) if part2(str(password))]
    print(len(candidates_part2))
コード例 #40
0
    def test_groups(self):
        test_input = get_input('test_input.txt')
        retrieved_groups = list(groups(test_input))

        self.assertTrue(len(retrieved_groups), 5)
        self.assertEqual(retrieved_groups[0], list('abc'))
        self.assertEqual(retrieved_groups[1], list('abc'))
        self.assertEqual(retrieved_groups[2], list('abc'))
        self.assertEqual(retrieved_groups[3], list('a'))
        self.assertEqual(retrieved_groups[4], list('b'))
コード例 #41
0
 def test_walkable(self):
     maze = get_input(20, test=1, strip=False)
     expected_walkable = {(9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (10, 3), (11, 3), (12, 3),
                          (13, 3), (14, 3), (15, 3), (16, 3), (17, 3), (17, 4), (17, 5), (17, 6), 
                          (17, 7), (17, 8), (17, 9), (17, 10), (17, 11), (17, 12), (17, 13), (17, 14), 
                          (17, 15), (16, 15), (15, 15), (14, 15), (13, 15), (13, 16), (13, 14), (13, 13), 
                          (12, 13), (11, 13), (11, 12), (2, 15), (3, 15), (3, 14), (3, 13), (2, 13), 
                          (2, 8), (3, 8), (4, 8), (4, 9), (4, 10), (5, 10), (6, 10)}
     walkable = get_walkable(maze)
     self.assertEqual(walkable, expected_walkable)
コード例 #42
0
 def test_gyro_sensor(self):
     get_input('Attach a GyroSensor then continue')
     d = GyroSensor()
     get_input('test ang')
     print(d.ang)
     print(d.mode)
     get_input('test rate')
     print(d.rate)
     print(d.mode)
     get_input('test ang_and_rate')
     print(d.ang_and_rate)
     print(d.mode)
コード例 #43
0
ファイル: day5.py プロジェクト: dmcnavish/adventOfCode
def main():
    jumps_input = get_input('../input/day5.in')

    jumps = map(int, jumps_input)
    steps = process_instructions(jumps, False)
    print "part1 steps: " + str(steps)

    jumps = map(int, jumps_input)
    steps = process_instructions(jumps, True)
    print "part2 steps: " + str(steps)
コード例 #44
0
ファイル: day08.py プロジェクト: cescara/aoc2019
def main():
    with open(get_input(__file__)) as file:
        file_input = file.read().strip()

    layers = [
        file_input[layer:layer + 25 * 6]
        for layer in range(0, len(file_input), 25 * 6)
    ]
    part1(layers.copy())
    part2(layers)
コード例 #45
0
 def test_absolute_IMU(self):
     get_input('Attach a AbsoluteIMU at port 2 then continue')
     d = AbsoluteIMU(2)
     print(d.version)
     get_input('test compass')
     print(d.compass)
     get_input('test x_gyro')
     print(d.x_gyro)
コード例 #46
0
def rename_command():
    project, file = eclim.get_context()    
    # we cannot read the code from TM via stdin, as it will not have 
    # the correct line endings when editing windows files (it will just have \n)
    #code = sys.stdin.read()

    # so we read from disk
    with open(os.environ["TM_FILEPATH"]) as f:
        code = f.read()
    pos = caret_position(code)
    identifier = current_identifier()
    pos = code.find(identifier, pos-len(identifier))
    
    new_name = util.get_input(default=identifier,title="Enter new name")
    
    call_eclim(project, file, len(identifier), pos, new_name)
コード例 #47
0
def count_and_sort():
    freqs = {}
    # The declaration for reactive observation of freqs
    observer = FreqObserver(freqs)
    # Let's get input from the user, or let her
    # feed the input automatically
    while get_input():
        try:
            w = non_stop_words().next()
            lock.acquire()
            freqs[w] = 1 if w not in freqs else freqs[w]+1
            lock.release()
        except StopIteration:
            # Let's wait for the observer thread to die gracefully
            observer.stop()
            sleep(1)
            break
コード例 #48
0
ファイル: x4_5_mod_password.py プロジェクト: 0x0mar/zarp
    def initialize(self):
        version = util.get_input('Enter Zoom version [2/3]: ')
        util.Msg('Changing admin password to \'d3fault\'...')

        url_25 = 'http://%s/hag/emweb/PopOutUserModify.htm/FormOne&user=admin&'\
                 'ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&id=3&'\
                 'cmdSubmit=Save+Changes' % self.config['target'].value
        url_30 = 'http://%s/hag/emweb/PopOutUserModify.htm?id=40&user=admin&'\
                 'Zadv=1&ex_param1=admin&new_pass1=d3fault&new_pass2=d3fault&'\
                 'id=3&cmdSubmit=Save+Changes' % self.config['target'].value
        url_logs = 'http://%s/Action?id=76&cmdClear+Log=Clear+Log' % self.config['target'].value

        try:
            if version == '2':
                urllib.urlopen(url_25).read()
            else:
                urllib.urlopen(url_30).read()

            util.Msg("Password reset, clearing logs...")
            urllib.urlopen(url_logs).read()
            util.Msg('Done.  Connect to %s with admin:d3fault' % self.config['target'].value)
        except Exception, e:
            util.Error('Unable to connect: %s' % e)
コード例 #49
0
ファイル: stirnn.py プロジェクト: Peratham/Numpy-RNNs
# hyperparameters
HIDDEN_LAYER_SIZE = 256
DEPTH = 3
DROPOUT_RATE = 0.1
STABILIZING_TERM_WEIGHT = 10

SEQ_SIZE = 100
BATCH_SIZE = 10
L_RATE = 0.002
MAX_ITERATIONS = 100000
EVAL_INTERVAL = 100
PRINT_SAMPLES = True
TEMPERATURE = 0.7

# get input
input, VOCABULARY_SIZE, char_to_index, index_to_char = util.get_input('shakespear_train.txt', -1)
validation_input, _, _, _, = util.get_input('shakespear_val.txt', 5000)

# model parameters
Wxh = [input_matrix_init(VOCABULARY_SIZE if d == 0 else HIDDEN_LAYER_SIZE, HIDDEN_LAYER_SIZE) for d in xrange(DEPTH)]
Whh = [recurrent_matrix_init_IRNN(HIDDEN_LAYER_SIZE) for d in xrange(DEPTH)]
bh = [np.zeros((1, HIDDEN_LAYER_SIZE)) for d in xrange(DEPTH)]
Why = np.random.randn(HIDDEN_LAYER_SIZE, VOCABULARY_SIZE) * 0.0001
by = np.zeros((1, VOCABULARY_SIZE))

def forward_backward(inputs, targets, initial_states):
	'''
	Computes forward and backward pass through the recurrent net, for SEQ_SIZE time steps
	-inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model
	-targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just the indices of the target chars
	-initial_states contains state of all the recurrent hidden units, shape [DEPTH, BATCH_SIZE, HIDDEN_LAYER_SIZE]
コード例 #50
0
ファイル: test_ev3_led.py プロジェクト: 2050utopia/python-ev3
 def test_led(self):
     get_input('Test LED')
     led = LED()
     get_input('Test left red')
     led.left.color=LED.COLOR.RED
     get_input('Test left green')
     led.left.color=LED.COLOR.GREEN
     get_input('Test left amber')
     led.left.color=LED.COLOR.AMBER
     get_input('Test right blink')
     led.right.blink(color=LED.COLOR.GREEN,delay_on=1000, delay_off=2000 )
     time.sleep(10)
     get_input('Test left and right on')
     led.left.on()
     led.right.on()
     time.sleep(5)
     get_input('Test left and right off')
     led.left.off()
     led.right.off()
コード例 #51
0
ファイル: test_ev3_i2cs.py プロジェクト: jdieter/python-ev3
 def test_i2cs(self):
     get_input("Attach an I2CS sensor on port 3 then continue")
     d = I2CS(port=3, addr=0x01)
     print(d.read_byte())
     print(d.read_byte_data(0x00))
コード例 #52
0
ファイル: testSonicII.py プロジェクト: ev3con/python-ev3con
from ev3.lego import UltrasonicSensor
from util import get_input

get_input('Start')

d = Ultrasonic_Sensor()
distStart = d.dist_cm
#Initialisiere System
while distStart == d.dist_cm:
 pass # Sobald sich der Wert ändere beginne mit der Aufzeichnung
timeStart = datetime.datetime.now()
distStart = d.dist_cm
while distStart == d.dist_cm:
 pass# Sobald sich der ert erneut ändert breche die Aufzeichnung ab
timeEnd = datetime.datetime.now()
distEnd = d.dist_cm
timeDiff = timeEnd - timeDiff
#print(timeDiff)
distDiff = distEnd - distStart
#print(distDiff)
timeDiff
distDiff
コード例 #53
0
    def count(self):
        def non_stop_words():
            stopwords = set(open('../stop_words.txt').read().split(',')  + list(string.ascii_lowercase))
            for line in f:
                yield [w for w in re.findall('[a-z]{2,}', line.lower()) if w not in stopwords]

        words = next(non_stop_words())
        lock.acquire()
        for w in words:
            self.freqs[w] = 1 if w not in self.freqs else self.freqs[w]+1
        lock.release()

#
# The controller
#
print("Press space bar to fetch words from the file one by one")
print("Press ESC to switch to automatic mode")
model = WordsCounter()
view = FreqObserver(model.freqs)
with open(sys.argv[1]) as f:
    while get_input():
        try:
            model.count()
        except StopIteration:
            # Let's wait for the view thread to die gracefully
            view.stop()
            sleep(1)
            break


コード例 #54
0
 def test_ultrasonic_sensor(self):
     get_input('Attach a UltrasonicSensor then continue')        
     d = UltrasonicSensor()        
     get_input('test dist_cm')
     print(d.dist_cm)
     print(d.mode)
     get_input('test dist_in')
     print(d.dist_in)
     print(d.mode)
     get_input('test listen')
     print(d.listen)
     print(d.mode)
     get_input('test si_cm')
     print(d.si_cm)
     print(d.mode)
     get_input('test si_in')
     print(d.si_in)
     print(d.mode)
コード例 #55
0
ファイル: test_ev3_key.py プロジェクト: 2050utopia/python-ev3
 def test_key(self):
     d = Key()
     get_input('Test keyboard. Hold Up key')
     print(d.up)
     get_input('Test keyboard. Release Up key')
     print(d.up)
     get_input('Test keyboard. Hold Down key')
     print(d.down)
     get_input('Test keyboard. Release Down key')
     print(d.down)
     get_input('Test keyboard. Hold Left key')
     print(d.left)
     get_input('Test keyboard. Release Left key')
     print(d.left)
     get_input('Test keyboard. Hold Right key')
     print(d.right)
     get_input('Test keyboard. Release Right key')
     print(d.right)
     get_input('Test keyboard. Hold Backspace key')
     print(d.backspace)
     get_input('Test keyboard. Release Backspace key')
     print(d.backspace)
     get_input('Test keyboard. Hold Enter key')
     print(d.enter)
     get_input('Test keyboard. Release Enter key')
     print(d.enter)
コード例 #56
0
 def test_touch_sensor(self):
     get_input('Attach a TouchSensor then continue')    	
     d = TouchSensor()
     get_input('test pushed')
     print(d.is_pushed)
     print(d.mode)