Skip to content

Commit

Permalink
Added caplog fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
krissowat committed Jul 24, 2023
1 parent 4658b2d commit b088beb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/aspire/source/micrograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(

if not np.allclose(self.simulation.offsets, 0):
logger.warning(
"We recommend simulating offsets of 0 for generating micrographs. Nonzero offsets will work but produce incomplete particles and other irregularities."
"We recommend setting simulation offsets to 0 for generating micrographs. Nonzero offsets will work but produce incomplete particles and other irregularities."
)

self.seed = seed
Expand Down
19 changes: 12 additions & 7 deletions tests/test_micrograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def test_noise_works():
assert np.array_equal(m.images[0], noisy_micrograph[0])


def test_nonzero_offsets_logger_works():
def test_nonzero_offsets_logger_works(caplog):
"""
Tests that nonzero offsets will still work but will give a logger warning. Using nonzero default for offset.
"""
Expand All @@ -316,10 +316,15 @@ def test_nonzero_offsets_logger_works():
amplitudes=1,
)
noise = WhiteNoiseAdder(1e-3)
_ = MicrographSimulation(
s,
noise_adder=noise,
micrograph_count=1,
particles_per_micrograph=4,
micrograph_size=200,
with caplog.at_level(logging.WARNING):
_ = MicrographSimulation(
s,
noise_adder=noise,
micrograph_count=1,
particles_per_micrograph=4,
micrograph_size=200,
)
assert (
"We recommend setting simulation offsets to 0 for generating micrographs. Nonzero offsets will work but produce incomplete particles and other irregularities."
in caplog.text
)

0 comments on commit b088beb

Please sign in to comment.