Add PGF.writeToFile. Add categoryProbability, but it seems pgf_category_prob always returns 0.

This commit is contained in:
John J. Camilleri
2021-09-27 11:37:52 +02:00
parent 187ded6d3d
commit 2deae9d402
5 changed files with 60 additions and 2 deletions

View File

@@ -77,6 +77,12 @@ def test_newNGF_existing(NGF):
with pytest.raises(FileExistsError):
newNGF("empty", "./basic.ngf")
# writePGF
def test_writePGF(PGF):
PGF.writeToFile("./copy.pgf")
os.remove("./copy.pgf") # cleanup
# abstract syntax
def test_abstractName(PGF):

View File

@@ -70,6 +70,11 @@ def test_original_function_prob(gr1):
# gr1.functionProbability("foo")
assert gr1.functionProbability("foo") == float('inf')
def test_original_category_prob(gr1):
# with pytest.raises(KeyError):
# gr1.categoryProbability("Q")
assert gr1.categoryProbability("Q") == float('inf')
# gr2
def test_extended_functions(gr2):
@@ -89,6 +94,9 @@ def test_extended_function_prob(gr2):
# assert gr2.functionProbability("foo") == prob
assert math.isclose(gr2.functionProbability("foo"), prob, rel_tol=1e-06)
def test_extended_category_prob(gr2):
assert gr2.categoryProbability("Q") == prob
# gr3
def test_branched_functions(gr3):