Skip to content

Commit 1e025e9

Browse files
committed
Additional linter repairs
Removed mutable default values. Removed equality comparisons against None.
1 parent 52b09ef commit 1e025e9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

popper/loop.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ def run(self, bkcons):
291291
# print('\t', 'moo', format_rule(rule))
292292
# new_cons.append((Constraint.SPECIALISATION, [functional_rename_vars(rule) for rule in x]))
293293

294-
# If a program is subsumed or dioesn't cover enough examples, we search for the most general subprogram that also is also subsumed or doesn't cover enough examples
294+
# If a program is subsumed or doesn't cover enough examples, we search for the most general
295+
# subprogram that is also subsumed or doesn't cover enough examples
295296
# only applies to non-recursive and non-PI programs
296297
subsumed_progs = []
297298
with settings.stats.duration('find most general subsumed/covers_too_few'):
@@ -635,7 +636,7 @@ def run(self, bkcons):
635636

636637
to_combine = set()
637638

638-
new_hypothesis_found = is_new_solution_found != None
639+
new_hypothesis_found = is_new_solution_found is not None
639640

640641
# if we find a new solution, update the maximum program size
641642
# if only adding nogoods, eliminate larger programs
@@ -728,7 +729,7 @@ def run(self, bkcons):
728729
is_new_solution_found = combiner.update_best_prog(to_combine)
729730
to_combine = set()
730731

731-
new_hypothesis_found = is_new_solution_found != None
732+
new_hypothesis_found = is_new_solution_found is not None
732733

733734
# if we find a new solution, update the maximum program size
734735
# if only adding nogoods, eliminate larger programs
@@ -1171,7 +1172,7 @@ def build_constraints_previous_hypotheses(self, score, best_size):
11711172
seen_hyp_gen[k].remove(to_del)
11721173
return cons
11731174

1174-
def subsumed_or_covers_too_few(self, prog, seen=set()):
1175+
def subsumed_or_covers_too_few(self, prog, seen:Optional[Set] = None):
11751176
tester, success_sets, settings = self.tester, self.success_sets, self.settings
11761177
head, body = list(prog)[0]
11771178
body = list(body)
@@ -1180,6 +1181,8 @@ def subsumed_or_covers_too_few(self, prog, seen=set()):
11801181
return []
11811182

11821183
out = set()
1184+
if seen is None:
1185+
seen = set()
11831186
head_vars = set(head.arguments)
11841187

11851188
# try the body with one literal removed (the literal at position i)
@@ -1290,10 +1293,14 @@ def build_test_prog(self, subprog):
12901293
def explain_totally_incomplete(self, prog):
12911294
return list(self.explain_totally_incomplete_aux2(prog, set(), set()))
12921295

1293-
def explain_totally_incomplete_aux2(self, prog, unsat2=set(), unsat=set()):
1296+
def explain_totally_incomplete_aux2(self, prog, unsat2: Optional[Set] = None, unsat: Optional[Set] = None):
12941297
has_recursion = prog_is_recursive(prog)
12951298

12961299
out = []
1300+
if unsat is None:
1301+
unsat = set()
1302+
if unsat2 is None:
1303+
unsat2 = set()
12971304
for subprog in generalisations(prog, allow_headless=True, recursive=has_recursion):
12981305

12991306
# print('---')

0 commit comments

Comments
 (0)