Skip to content

Commit

Permalink
Merge pull request #80 from bowen-xu/reset_in_test
Browse files Browse the repository at this point in the history
add setUp method to tests to perform nars.reset before each test case
  • Loading branch information
bowen-xu authored Nov 17, 2023
2 parents 2b96160 + 6cbefcb commit ebff7b9
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Tests/test_NAL/test_BUG_NAL4.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@


class TEST_BUG_NAL4(unittest.TestCase):
def setUp(self):
nars.reset()

''''''
def test_bug_0(self):
'''
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_NAL/test_NAL1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# utils_for_test.engine = RuleMap()

class TEST_NAL1(unittest.TestCase):
def setUp(self):
nars.reset()

def test_revision(self):
'''
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_NAL/test_NAL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@


class TEST_NAL2(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_revision(self):
Expand Down
6 changes: 6 additions & 0 deletions Tests/test_NAL/test_NAL3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@


class TEST_NAL3(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_compound_intersection_extension(self):
Expand Down Expand Up @@ -154,6 +157,7 @@ def test_compound_decomposition_intensional_intersection(self):
output_contains(tasks_derived, '<robin --> bird>. %1.00;0.81%')
)

nars.reset()

tasks_derived = process_two_premises(
'<robin --> swimmer>. %0.00;0.90%',
Expand Down Expand Up @@ -190,6 +194,8 @@ def test_compound_decomposition_extensional_difference(self):
output_contains(tasks_derived, '<robin --> mammal>. %0.00;0.81%')
)

nars.reset()

tasks_derived = process_two_premises(
'<robin --> (-,mammal,swimmer)>. %0.00;0.90%',
'<robin --> swimmer>. %0.00;0.90%',
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_NAL/test_NAL4.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@


class TEST_NAL4(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_structural_transformation_0(self):
Expand Down
12 changes: 12 additions & 0 deletions Tests/test_NAL/test_NAL5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@


class TEST_NAL5(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_revision(self):
Expand Down Expand Up @@ -180,6 +183,8 @@ def test_conditional_deduction_0(self):
output_contains(tasks_derived, '<robin --> animal>. %1.00;0.81%')
)

nars.reset()

tasks_derived = process_two_premises(
'<robin --> bird>. %1.00;0.90%',
'<<robin --> bird> ==> <robin --> animal>>. %1.00;0.90%',
Expand Down Expand Up @@ -346,6 +351,8 @@ def test_conditional_analogy(self):
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
)

nars.reset()

tasks_derived = process_two_premises(
'<<robin --> bird> <=> <robin --> [flying]>>. %0.80;0.90%',
'<robin --> bird>. %1.00;0.90%',
Expand All @@ -355,6 +362,8 @@ def test_conditional_analogy(self):
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
)

nars.reset()

tasks_derived = process_two_premises(
'<robin --> bird>. %1.00;0.90%',
'<<robin --> [flying]> <=> <robin --> bird>>. %0.80;0.90%',
Expand All @@ -364,6 +373,7 @@ def test_conditional_analogy(self):
output_contains(tasks_derived, '<robin --> [flying]>. %0.80;0.65%')
)

nars.reset()

tasks_derived = process_two_premises(
'<<robin --> [flying]> <=> <robin --> bird>>. %0.80;0.90%',
Expand Down Expand Up @@ -581,6 +591,8 @@ def test_decomposition_1(self):
output_contains(tasks_derived, '<robin --> swimmer>. %0.00;0.81%')
)

nars.reset()

tasks_derived = process_two_premises(
'<robin --> [flying]>. %1.00;0.90%',
'(&&,<robin --> [flying]>,<robin --> swimmer>). %0.00;0.90% ',
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_NAL/test_NAL6.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from pynars.NARS.InferenceEngine.VariableEngine.VariableEngine import VariableEngine

class TEST_NAL6(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_unification_0(self):
Expand Down
6 changes: 6 additions & 0 deletions Tests/test_NAL/test_NAL7.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# utils_for_test.rule_map = RuleMap_v2()

class TEST_NAL7(unittest.TestCase):
def setUp(self):
nars.reset()

''''''

def test_deduction(self):
Expand Down Expand Up @@ -634,6 +637,9 @@ def test_deduction_sequence(self):
pass

class TEST_NAL7_ANALOGY(unittest.TestCase):
def setUp(self):
nars.reset()

def test_analogy_0_0__0(self):
'''
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_NAL/test_NAL8.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@


class TEST_NAL8(unittest.TestCase):
def setUp(self):
nars.reset()

''''''
def test_1_0(self):
'''
Expand Down
5 changes: 5 additions & 0 deletions Tests/test_NAL/test_NAL9.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
nars = utils_for_test.nars

class TEST_NAL9(unittest.TestCase):
def setUp(self):
nars.reset()

''''''
def test_anticipate_0(self):
'''
Expand Down Expand Up @@ -76,6 +79,8 @@ def test_doubt_0(self):
100
)

nars.reset()

tasks_derived = process_two_premises(
'<a --> b>?',
None,
Expand Down
4 changes: 1 addition & 3 deletions Tests/utils_for_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

def process_two_premises(premise1: str, premise2: str, n_cycle: int) -> List[Task]:
''''''
nars.reset()

tasks_all_cycles = []

success, task, task_overflow = nars.input_narsese(premise1)
Expand All @@ -43,7 +41,7 @@ def process_two_premises(premise1: str, premise2: str, n_cycle: int) -> List[Tas
if answers_quest is not None:
tasks_all_cycles.extend(answers_quest)

return tasks_all_cycles
return [t for t in tasks_all_cycles if t is not None]

def rule_map_two_premises(premise1: str, premise2: str, term_common: str, inverse: bool=False, is_belief_term: bool=False, index_task=None, index_belief=None) -> Tuple[List[RuleCallable], Task, Belief, Concept, TaskLink, TermLink, Tuple[Task, Task, Task, Task]]:
''''''
Expand Down

0 comments on commit ebff7b9

Please sign in to comment.