mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-10 21:39:32 -06:00
Add PGF.writeToFile. Add categoryProbability, but it seems pgf_category_prob always returns 0.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user