-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
CIContinuous IntegrationContinuous Integration
Description
Many tests rely on the saved 70S ribosome volume, e.g.
ASPIRE-Python/tests/test_volume.py
Lines 316 to 323 in 6cb389e
| def testDownsample(self): | |
| # Data files re-used from test_preprocess | |
| vols = Volume(np.load(os.path.join(DATA_DIR, "clean70SRibosome_vol.npy"))) | |
| resv = Volume(np.load(os.path.join(DATA_DIR, "clean70SRibosome_vol_down8.npy"))) | |
| result = vols.downsample((8, 8, 8)) | |
| self.assertTrue(np.allclose(result, resv)) |
However, we should replace these with self-contained tests based on gaussian volumes, and test mathematical properties rather than compare to hardcoded files. Good examples are below:
ASPIRE-Python/tests/test_preprocess_pipeline.py
Lines 113 to 124 in 6cb389e
| def testWhiten(self): | |
| noise_estimator = AnisotropicNoiseEstimator(self.sim) | |
| self.sim.whiten(noise_estimator.filter) | |
| imgs_wt = self.sim.images(start=0, num=self.n).asnumpy() | |
| # calculate correlation between two neighboring pixels from background | |
| corr_coef = np.corrcoef( | |
| imgs_wt[:, self.L - 1, self.L - 1], imgs_wt[:, self.L - 2, self.L - 1] | |
| ) | |
| # correlation matrix should be close to identity | |
| self.assertTrue(np.allclose(np.eye(2), corr_coef, atol=1e-1)) |
ASPIRE-Python/tests/test_preprocess_pipeline.py
Lines 82 to 99 in 6cb389e
| # Check individual grid points | |
| self.assertTrue( | |
| np.allclose( | |
| imgs_org[:, 32, 32], | |
| imgs_ds[:, 16, 16], | |
| atol=utest_tolerance(self.dtype), | |
| ) | |
| ) | |
| # check resolution | |
| self.assertTrue(np.allclose(max_resolution, imgs_ds.shape[1])) | |
| # check energy conservation after downsample | |
| self.assertTrue( | |
| np.allclose( | |
| anorm(imgs_org.asnumpy(), axes=(1, 2)) / self.L, | |
| anorm(imgs_ds.asnumpy(), axes=(1, 2)) / max_resolution, | |
| atol=utest_tolerance(self.dtype), | |
| ) | |
| ) |
janden
Metadata
Metadata
Assignees
Labels
CIContinuous IntegrationContinuous Integration