Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds unit tests #41

Merged
merged 29 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b055f93
created few unit tests for bp_utils
Jul 30, 2021
faef39b
Merge branch 'vicariousinc:master' into unit_tests
NishanthJKumar Jul 30, 2021
7b25f33
Merge branch 'vicariousinc:master' into unit_tests
NishanthJKumar Aug 2, 2021
f12001e
includes first E2E test for pgmax
Aug 2, 2021
e17f697
adds new tests
Aug 2, 2021
0835ef8
Merge branch 'master' of github.com:vicariousinc/PGMax into vicarious…
Aug 13, 2021
407ccee
Merge branch 'vicariousinc-master' into unit_tests
Aug 13, 2021
2c7ab3c
updates sanity check and E2E test, but test currently fails
Aug 13, 2021
99501b4
adds coverage dependency to poetry
NishanthJKumar Aug 18, 2021
e0460e7
Merge branch 'unit_tests' into master
NishanthJKumar Aug 18, 2021
acaf801
Merge pull request #7 from NishanthJKumar/master
NishanthJKumar Aug 18, 2021
a6a32ff
small update to test_pgmax
NishanthJKumar Aug 18, 2021
f1811aa
adds codecov to CI
NishanthJKumar Aug 19, 2021
bf78603
test codecov upload with github secret
NishanthJKumar Aug 19, 2021
944297d
updates ci and poetry deps
NishanthJKumar Aug 19, 2021
e2afc5f
fixes command error in ci
NishanthJKumar Aug 19, 2021
46188df
fixes codecov yaml to be parseable
NishanthJKumar Aug 19, 2021
c5aa087
Merge branch 'master' of github.com:vicariousinc/PGMax into vicarious…
NishanthJKumar Aug 19, 2021
889479c
Merge branch 'vicariousinc-master' into unit_tests
NishanthJKumar Aug 19, 2021
cbac54a
updates ci to only run build on PR's again!
NishanthJKumar Aug 19, 2021
db8f120
testing codecov from personal fork
NishanthJKumar Aug 20, 2021
8472fd4
updates tests
NishanthJKumar Aug 21, 2021
43ccf99
adds simple e2e test inspired by the heretic model
NishanthJKumar Aug 22, 2021
2ab9fbe
includes tests reaching 95% coverage of pgmax
NishanthJKumar Aug 22, 2021
d75050e
adds more tests to get to 97% overall coverage
NishanthJKumar Aug 24, 2021
ed293af
updates tests to 100% coverage
NishanthJKumar Aug 24, 2021
401f629
addresses first major round of comments on #41
NishanthJKumar Aug 25, 2021
e894d9d
Update tests/fg/test_groups.py
NishanthJKumar Aug 25, 2021
52fdfa0
addresses second round of comments on #41
NishanthJKumar Aug 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds more tests to get to 97% overall coverage
  • Loading branch information
NishanthJKumar committed Aug 24, 2021
commit d75050e9309e10a81554438df45f193b7521a8e9
4 changes: 2 additions & 2 deletions pgmax/fg/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def get_vars_to_evidence(

Args:
evidence: A mapping or a sequence of evidences.
The type of evidence should match that of self.variable_group_container
The type of evidence should match that of self.variable_group_container.

Returns:
a dictionary mapping all possible variables to the corresponding evidence
Expand Down Expand Up @@ -337,7 +337,7 @@ def get_vars_to_evidence(

if evidence[key].shape != (self.variable_size,):
raise ValueError(
f"Variable {key} expect an evidence array of shape "
f"Variable {key} expects an evidence array of shape "
f"({(self.variable_size,)})."
f"Got {evidence[key].shape}."
)
Expand Down
32 changes: 32 additions & 0 deletions tests/fg/test_groups.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import pytest

from pgmax.fg import groups
Expand All @@ -21,3 +22,34 @@ def test_composite_vargroup_valueerror():
with pytest.raises(ValueError) as verror:
comp_var_group[tuple([0])]
assert "The key needs" in str(verror.value)


def test_composite_vargroup_evidence():
NishanthJKumar marked this conversation as resolved.
Show resolved Hide resolved
v_group1 = groups.GenericVariableGroup(3, tuple([0, 1, 2]))
v_group2 = groups.GenericVariableGroup(3, tuple([0, 1, 2]))
comp_var_group = groups.CompositeVariableGroup(tuple([v_group1, v_group2]))
assert (
len(
comp_var_group.get_vars_to_evidence(
[{0: np.zeros(3)}, {0: np.zeros(3)}]
).keys()
)
== 2
)


def test_ndvararray_evidence_error():
v_group = groups.NDVariableArray(3, (2, 2))
with pytest.raises(ValueError) as verror:
v_group.get_vars_to_evidence(np.zeros((1, 1)))
assert "Input evidence" in str(verror.value)


def test_generic_evidence_errors():
v_group = groups.GenericVariableGroup(3, tuple([0]))
with pytest.raises(ValueError) as verror:
v_group.get_vars_to_evidence({1: np.zeros((1, 1))})
assert "The evidence is referring" in str(verror.value)
with pytest.raises(ValueError) as verror:
v_group.get_vars_to_evidence({0: np.zeros((1, 1))})
assert "expects an evidence array" in str(verror.value)