Beispiel #1
0
    def start(self, version):
        """Display the menu, wait for user input and then run the program

        Parameters:
            version - version number
        """
        # display menu and ask for input file path
        filePath = None
        cwdpath = ''
        while not filePath:
            cwdpath, filePath = self.displayMenu(version)

        # merge working directory and file path
        totalPath = os.path.join(cwdpath, filePath)

        # call program selector
        program = Program(cwdpath, totalPath)
        timer = Timer()
        timer.tic()
        try:
            program.run()
        except NoInputFileException as e:
            print e.message
        timer.toc()
        self.logger.info(timer.string('\n' 'iFlow run time'))

        # upon closing, ask input before ending. This to keep plot windows open.
        # self.askClose()

        return
Beispiel #2
0
def part_one():

    # Setup
    program = Program(1024 * 1024)
    program.load_code("testInput.txt")

    # Run
    #program.load_input([1])
    program.run()
    print(program.is_done())

    output = program.get_output()
    print(output)
Beispiel #3
0
def run(program: Program, args: ArgsMap) -> ProgramResult:
    try:
        return program.run(**mk_func_args(
            program.run, ArgsMapSeries.make(args, as_argsmap(program))))
    except Fizzle as fiz:
        if fiz.codelet is None:
            force_setattr(fiz, 'codelet', program)
        raise
Beispiel #4
0
def part_one():

	# Setup program
	program = Program()
	program.load_code("thrusterProgram.txt")

	# Try all phase setting permutations
	phase_configuration_permutations = itertools.permutations([0, 1, 2, 3, 4])
	
	max_output = 0
	for phase_configuration in phase_configuration_permutations:
		
		output = 0
		for phase in phase_configuration:	

			program.load_input([output, phase])
			program.reset()
			program.run()
			output = program.get_output()

		if output > max_output:
			max_output = output

	print("Highest signal to thrusters is: %d" % max_output)
Beispiel #5
0
    def test_run_invalid_input(self):
        program = Program()
        program.transport = mock.create_autospec(Transport)
        program.parser = mock.create_autospec(Parser)
        program.interpolator = mock.create_autospec(Interpolator)

        program.transport.read.return_value = 'input'
        program.parser.parse.side_effect = ValueError('Error')
        program.interpolator.interpolate.return_value = 'output'

        actual = program.run()

        program.transport.read.assert_called()
        program.parser.parse.assert_called()
        program.parser.parse.assert_called_with('input')
        program.interpolator.interpolate.assert_not_called()
        program.transport.write.assert_called_with('Invalid matrix!')
Beispiel #6
0
    def test_run(self):
        program = Program()
        program.transport = mock.create_autospec(Transport)
        program.parser = mock.create_autospec(Parser)
        program.interpolator = mock.create_autospec(Interpolator)

        program.transport.read.return_value = 'input'
        program.parser.parse.return_value = 'parsed_input'
        program.interpolator.interpolate.return_value = 'output'

        actual = program.run()

        program.transport.read.assert_called()
        program.parser.parse.assert_called()
        program.parser.parse.assert_called_with('input')
        program.interpolator.interpolate.assert_called_with('parsed_input')
        program.transport.write.assert_called_with('output')
Beispiel #7
0
def part_one_and_two():

    program = Program()
    program.load_code("input.txt")
    program.run()
Beispiel #8
0
from Program import Program
from Relation import Relation
from Infer import Infer
#Doc file input
fp = input('Nhập tên  file input: ')
f = open(fp, 'r')
f1 = f.read().splitlines()
KB = []
I = []
questions = []
flag = 0
for x in f1:
    if x == '*':
        flag += 1
        continue
    if flag == 0:
        temp = Relation(x)
        KB.append(temp)
    elif flag == 1:
        temp = Infer(x)
        I.append(temp)
    else:
        questions.append(x)
f.close()

main = Program(KB, I)
main.run()
#main.printKB()
main.writeAnswer(questions)
Beispiel #9
0
from Program import Program

if __name__ == '__main__':
    program = Program()
    program.run()