Fix vacuous reset_parameters tests - #377
Conversation
The reset_parameters tests of HSNLayer, SCConvLayer and SCN2Layer only asserted on torch.nn.Conv2d modules, which these layers do not contain, so the loop body never executed and the tests passed without checking anything. The zeros comparison would have been wrong regardless, since the layers initialize with Xavier schemes. Fill all parameters with a sentinel value, reset, and assert that every parameter changed and remains finite. Fixes #140
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
==========================================
- Coverage 96.43% 96.36% -0.08%
==========================================
Files 58 58
Lines 2078 2090 +12
==========================================
+ Hits 2004 2014 +10
- Misses 74 76 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes vacuous reset_parameters unit tests for several simplicial layers by replacing an incorrect torch.nn.Conv2d-based assertion (which never ran) with a sentinel-based approach that verifies parameters are actually reinitialized.
Changes:
- Fill all layer parameters with a sentinel value under
torch.no_grad(). - Call
reset_parameters()and assert each parameter is finite. - Assert each parameter tensor is no longer entirely equal to the sentinel value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/nn/simplicial/test_scn2_layer.py |
Makes reset_parameters test non-vacuous by sentinel-filling parameters and verifying they change and remain finite. |
test/nn/simplicial/test_scconv_layer.py |
Same sentinel-based validation for SCConvLayer.reset_parameters(). |
test/nn/simplicial/test_hsn_layer.py |
Same sentinel-based validation for HSNLayer.reset_parameters(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The reset_parameters tests of HSNLayer, SCConvLayer and SCN2Layer only asserted on torch.nn.Conv2d modules, which these layers do not contain, so the loop body never executed and the tests passed without checking anything. The zeros comparison would have been wrong regardless, since the layers initialize with Xavier schemes.
Fill all parameters with a sentinel value, reset, and assert that every parameter changed and remains finite.
Fixes #140