Skip to content

Commit

Permalink
Move lr fp tests to recur
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Oct 28, 2024
1 parent 8bf17fc commit 9080954
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 34 deletions.
52 changes: 18 additions & 34 deletions test/test_holdouts.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from unittest import TestCase

from test.utils import read_holdouts
from test.lin_rec import (
StrictLinRecMachine,
run_loose_linrec_machine,
)

from tm.machine import quick_term_or_rec

Expand All @@ -21,20 +17,21 @@

TOTAL_HOLDOUTS = 883

PY_FALSE_POSIIVES = {
"1RB 0RB 0LB 1RC 1LD 0RC 1LB 1LA",
"1RB 0RB 0LC 1RD 1LC 1LA 1LB 0RD",
"1RB 1LD 1LC 1RB 0RC 1LA 0RD 0LC",
}

RUST_FALSE_POSITIVES = {
"1RB ... 1RC 0RA 0LD 0LB 0RB 1LC",
"1RB 0LD 1LC 1RA ... 1LD 0RD 1LA",
"1RB 0RC 0LB 1LA ... 1RD 1LB 0RD",
"1RB 0RD 0LC 0LA 1LA 1LB 1RA ...",
"1RB 1LA 0LC 0LD ... 1LD 0RD 1RA",
"1RB 1LC 0LA 0RD 1RC 1LB ... 1RA",
"1RB 1LC 0LA 0RD 1RD 1LB ... 1RA",
LR_FALSE_POSITIVES = {
"py": {
"1RB 0RB 0LB 1RC 1LD 0RC 1LB 1LA",
"1RB 0RB 0LC 1RD 1LC 1LA 1LB 0RD",
"1RB 1LD 1LC 1RB 0RC 1LA 0RD 0LC",
},
"rs": {
"1RB ... 1RC 0RA 0LD 0LB 0RB 1LC",
"1RB 0LD 1LC 1RA ... 1LD 0RD 1LA",
"1RB 0RC 0LB 1LA ... 1RD 1LB 0RD",
"1RB 0RD 0LC 0LA 1LA 1LB 1RA ...",
"1RB 1LA 0LC 0LD ... 1LD 0RD 1RA",
"1RB 1LC 0LA 0RD 1RC 1LB ... 1RA",
"1RB 1LC 0LA 0RD 1RD 1LB ... 1RA",
}
}


Expand All @@ -56,23 +53,10 @@ def test_holdouts(self):
TOTAL_HOLDOUTS)

for prog in holdouts:
self.assertFalse(
quick_term_or_rec(prog, STEPS),
prog)

if prog in PY_FALSE_POSIIVES:
self.assertIsNotNone(
run_loose_linrec_machine(prog, 300).infrul)

if any(prog in progs
for progs in LR_FALSE_POSITIVES.values()):
continue

self.assertIsNotNone(
run_loose_linrec_machine(prog, STEPS).xlimit)

for prog in RUST_FALSE_POSITIVES:
self.assertTrue(
self.assertFalse(
quick_term_or_rec(prog, STEPS),
prog)

self.assertIsNotNone(
StrictLinRecMachine(prog).run(STEPS // 2).xlimit)
29 changes: 29 additions & 0 deletions test/test_turing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# pylint: disable-next = wildcard-import, unused-wildcard-import
from test.prog_data import *
from test.test_num import assert_num_counts, clear_caches
from test.test_holdouts import LR_FALSE_POSITIVES
from test.lin_rec import (
LinRecSampler,
run_loose_linrec_machine,
Expand Down Expand Up @@ -520,6 +521,34 @@ def run_bb(

self.analyze(prog)

def test_lr_false_positives(self):
steps = 1_000

for progs in LR_FALSE_POSITIVES.values():
for prog in progs:
self.assertIsNotNone(
StrictLinRecMachine(prog).run(steps).xlimit)

for prog in LR_FALSE_POSITIVES["py"]:
# good
self.assertFalse(
quick_term_or_rec(prog, steps),
prog)

# bad
self.assertIsNone(
run_loose_linrec_machine(prog, steps).xlimit)

for prog in LR_FALSE_POSITIVES["rs"]:
# bad
self.assertTrue(
quick_term_or_rec(prog, steps),
prog)

# bad
self.assertIsNone(
run_loose_linrec_machine(prog, steps).xlimit)

def test_recur(self):
self._test_recur(
RECUR_COMPACT
Expand Down

0 comments on commit 9080954

Please sign in to comment.