Skip to content

Commit beaea3c

Browse files
committed
Use anorm to normalize each image instead of whole stack
1 parent 733aca1 commit beaea3c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_preprocess_pipeline.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from aspire.source.simulation import Simulation
1010
from aspire.utils import utest_tolerance
1111
from aspire.utils.coor_trans import grid_2d, grid_3d
12+
from aspire.utils.matrix import anorm
1213
from aspire.volume import Volume
1314

1415
DATA_DIR = os.path.join(os.path.dirname(__file__), "saved_test_data")
@@ -38,7 +39,12 @@ def testPhaseFlip(self):
3839
imgs_pf = self.sim.images(start=0, num=self.n)
3940

4041
# 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+
)
4248

4349
def testDownsample(self):
4450
# generate a 3D map with density decays as Gaussian function
@@ -86,8 +92,8 @@ def testDownsample(self):
8692
# check energy conservation after downsample
8793
self.assertTrue(
8894
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,
9197
atol=utest_tolerance(self.dtype),
9298
)
9399
)

0 commit comments

Comments
 (0)