Skip to content

Commit

Permalink
Undo a thing from previous commit; add test (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
prisae authored Aug 19, 2021
1 parent 6e2e37a commit 39873c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion emg3d/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ def print_solver_info(self, field='efield', verb=1, return_info=False):
cinfo = info[src][freq]

# Print if verbose or not converged.
if verb > 0 or cinfo['exit'] != 0:
if cinfo is not None and (verb > 0 or cinfo['exit'] != 0):

# Initial message.
if not out:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,22 @@ def test_print_solver(self, capsys):
out, _ = capsys.readouterr()
assert "= Source TxED-1; Frequency 1.0 Hz = CONVERGED" in out

# Two sources, only compute 1, assure printing works.
sources = [emg3d.TxElectricDipole((x, 0, 0, 0, 0)) for x in [0, 10]]
survey = emg3d.Survey(
name='Test', sources=sources,
receivers=receivers,
frequencies=1.0, noise_floor=1e-15, relative_error=0.05,
)

inp = {'name': 'Test', 'survey': survey, 'model': model,
'gridding': 'same'}
simulation = simulations.Simulation(**inp, solver_opts={'verb': 0})
_ = simulation.get_efield('TxED-2', 'f-1')
simulation.print_solver_info(verb=1)
out, _ = capsys.readouterr()
assert "= Source TxED-2; Frequency 1.0 Hz = CONVERGED" in out

def test_rel_abs_rec(self):
# Sources
sources = emg3d.surveys.txrx_coordinates_to_dict(
Expand Down

0 comments on commit 39873c9

Please sign in to comment.