def test_run() -> None: assert Solver.run("1/2 + 3/4") == "1_1/4" assert Solver.run("1 + 0") == "1" assert Solver.run("3_1/2 * 3") == "10_1/2" assert Solver.run("2_4/5 - 11/10") == "1_7/10" assert Solver.run("10 / 2") == "5" assert Solver.run("13/2 / 3/2") == "4_1/3" assert Solver.run("-1_1/3 - 1/3") == "-1_2/3" assert Solver.run("-1/2 * 2") == "-1"
def calculator() -> None: click.echo( click.style( ("Welcome, please enter an operation.\n" "E.g. 1 + 2, 1/2 - 3/4, 2_2/3 / -8_1/5\n" "Press Ctrl+C to exit."), fg="magenta", )) while True: input = click.prompt(click.style("?", fg="green")) try: click.echo( click.style("= ", fg="blue") + click.style(Solver.run(input), fg="yellow")) except ValueError as excinfo: click.echo(click.style(str(excinfo), fg="red"))
cnt = 0 print("{:<20} {:<10}".format('PHM positions', 'Failure of critical function')) print("------------- ----------------------------") for state in states: cnt += 1 if select and cnt < number: continue if select and cnt > number: break model_description = model.load_phm(model_description, state) # Build the model bn = BayesianNetwork(model_description) bayesian_model = bn.build() solver = Solver(bayesian_model, display, evidence) e = solver.run(mapquery=False, printed=False) if e < failure: final_state = state failure = e print("{:<20} {:.4E} *".format(cnt, e)) else: print("{:<20} {:.4E}".format(cnt, e)) if details: print('\n=====================\n') model_description = model.load_phm(model_description, final_state) # Build the model bn = BayesianNetwork(model_description) bayesian_model = bn.build() solver = Solver(bayesian_model, display_final, evidence) e = solver.run(mapquery=False, printed=True) print('\n=====================\n')
from src.solver import Solver for i in range(2, 42): runner = Solver() print("========================================================") print(i.__str__() + "begin :: ") runner.run("../dataset/raw_datas/g" + i.__str__())
def main(): parser = setup_parser() args = parser.parse_args() solver = Solver(args.text_file) solver.run()