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
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 simple e2e test inspired by the heretic model
  • Loading branch information
NishanthJKumar committed Aug 22, 2021
commit 43ccf999d92d27d4bd221c9d1e93b5811e708aaf
48 changes: 48 additions & 0 deletions tests/test_pgmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,51 @@ def create_valid_suppression_config_arr(suppression_diameter):

# Test that the output messages are close to the true messages
assert jnp.allclose(final_msgs, true_final_msgs_output, atol=1e-06)


def test_e2e_heretic():
# Define some global constants
im_size = (30, 30)
prng_key = jax.random.PRNGKey(42)

# Instantiate all the Variables in the factor graph via VariableGroups
pixel_vars = groups.NDVariableArray(3, im_size)
hidden_vars = groups.NDVariableArray(
17, (im_size[0] - 2, im_size[1] - 2)
) # Each hidden var is connected to a 3x3 patch of pixel vars
composite_vargroup = groups.CompositeVariableGroup((pixel_vars, hidden_vars))

bXn = np.zeros((30, 30, 3))
bHn = np.zeros((28, 28, 17))

# Create the factor graph
fg = graph.FactorGraph((pixel_vars, hidden_vars))

# Assign evidence to pixel vars
fg.set_evidence(0, np.array(bXn))
fg.set_evidence(1, np.array(bHn))

def binary_connected_variables(
num_hidden_rows, num_hidden_cols, kernel_row, kernel_col
):
ret_list: List[List[Tuple[Any, ...]]] = []
for h_row in range(num_hidden_rows):
for h_col in range(num_hidden_cols):
ret_list.append(
[
(1, h_row, h_col),
(0, h_row + kernel_row, h_col + kernel_col),
]
)
return ret_list

W_pot = np.zeros((17, 3, 3, 3), dtype=float)
for k_row in range(3):
for k_col in range(3):
fg.add_factors(
factor_factory=groups.PairwiseFactorGroup,
connected_var_keys=binary_connected_variables(28, 28, k_row, k_col),
log_potential_matrix=W_pot[:, :, k_row, k_col],
)

assert len(fg._factors) == 7056