def test_eq(self, capfd): cli_args = ['-ic', '-cd', '1', '-tl', '-rs', '0', 'fl', '-s', '1', '-a', '0.13', '-sgs'] case = run_dwig_cli(self.parser, cli_args) coefficients = [qt['coeff'] for qt in case['quadratic_terms']] assert(sum(c > 0 for c in coefficients) == 1)
def test_eq(self, capfd): cli_args = ['-ic', '-cd', '2', '-tl', '-rs', '0', 'fl'] json_base = run_dwig_cli(self.parser, cli_args) cli_args.append('-sgs') json_sgs = run_dwig_cli(self.parser, cli_args) base_solution_eval = json_base['solutions'][0]['evaluation'] sgs_solution_eval = json_sgs['solutions'][0]['evaluation'] assert(abs(base_solution_eval - sgs_solution_eval) <= 1e-8)
def test_cell_limit(self, capfd): for cell_limit in range(1, 9): cli_args = [ '-ic', '-cd', '3', '-tl', '-rs', '0', '-ccl', str(cell_limit), 'ran' ] json_base = run_dwig_cli(self.parser, cli_args) assert (len(json_base['variable_ids']) == 8 * cell_limit)
def test_sgs(self, capfd): cli_args = ['-cd', '2', '-tl', '-rs', '0', 'ran', '-sgs', '-pr', '1.0'] json_base = run_dwig_cli(self.parser, cli_args) for lt in json_base['linear_terms']: assert (lt['coeff'] == 0.0) for qt in json_base['quadratic_terms']: assert (qt['coeff'] <= -1.0)