|
9 | 9 | from aspire.source.simulation import Simulation |
10 | 10 | from aspire.utils import utest_tolerance |
11 | 11 | from aspire.utils.coor_trans import grid_2d, grid_3d |
| 12 | +from aspire.utils.matrix import anorm |
12 | 13 | from aspire.volume import Volume |
13 | 14 |
|
14 | 15 | DATA_DIR = os.path.join(os.path.dirname(__file__), "saved_test_data") |
@@ -38,7 +39,12 @@ def testPhaseFlip(self): |
38 | 39 | imgs_pf = self.sim.images(start=0, num=self.n) |
39 | 40 |
|
40 | 41 | # check energy conservation |
41 | | - self.assertTrue(np.allclose(self.imgs_org.norm(), imgs_pf.norm())) |
| 42 | + self.assertTrue( |
| 43 | + np.allclose( |
| 44 | + anorm(self.imgs_org.asnumpy(), axes=(1, 2)), |
| 45 | + anorm(imgs_pf.asnumpy(), axes=(1, 2)), |
| 46 | + ) |
| 47 | + ) |
42 | 48 |
|
43 | 49 | def testDownsample(self): |
44 | 50 | # generate a 3D map with density decays as Gaussian function |
@@ -86,8 +92,8 @@ def testDownsample(self): |
86 | 92 | # check energy conservation after downsample |
87 | 93 | self.assertTrue( |
88 | 94 | np.allclose( |
89 | | - imgs_org.norm() / self.L, |
90 | | - imgs_ds.norm() / max_resolution, |
| 95 | + anorm(imgs_org.asnumpy(), axes=(1, 2)) / self.L, |
| 96 | + anorm(imgs_ds.asnumpy(), axes=(1, 2)) / max_resolution, |
91 | 97 | atol=utest_tolerance(self.dtype), |
92 | 98 | ) |
93 | 99 | ) |
|
0 commit comments