Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions empymod/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
check_solution, get_abs, get_geo_fact, get_azm_dip, get_off_ang,
get_layer_nr, get_kwargs, printstartfinish, conv_warning, EMArray)

try:
import empygrad
except ImportError:
empygrad = None

__all__ = ['bipole', 'dipole', 'loop', 'analytical', 'gpr', 'dipole_k',
'ip_and_q', 'fem', 'tem']

Expand Down Expand Up @@ -829,6 +834,22 @@ def dipole(src, rec, depth, res, freqtime, signal=None, ab=11, aniso=None,
Out[1]: (1.6880934577857306e-10-3.083031298956568e-10j)

"""

# Crude wrapper for empygrad for testing purposes.
if kwargs.pop('gradient', False):
if empygrad:
return empygrad.dipole(
src, rec, depth, res, freqtime, signal, ab, aniso, epermH,
epermV, mpermH, mpermV, **kwargs
)
else:
msg = (
"Keyword `gradient` requires the missing soft dependency "
"empygrad."
)
warnings.warn(msg, UserWarning)
return False

# Get kwargs with defaults.
out = get_kwargs(
[
Expand Down
4 changes: 2 additions & 2 deletions empymod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ class Report(ScoobyReport):
Always shown are the OS, number of CPU(s), `numpy`, `scipy`, `numba`,
`empymod`, `sys.version`, and time/date.

Additionally shown are, if they can be imported, `IPython`, and
Additionally shown are, if they can be imported, `empygrad`, `IPython`, and
`matplotlib`. It also shows MKL information, if available.

All modules provided in `add_pckg` are also shown.
Expand Down Expand Up @@ -2253,7 +2253,7 @@ def __init__(self, add_pckg=None, ncol=3, text_width=80, sort=False):
core = ['numpy', 'scipy', 'numba', 'empymod', 'libdlf']

# Optional packages.
optional = ['IPython', 'matplotlib']
optional = ['IPython', 'matplotlib', 'empygrad']

super().__init__(additional=add_pckg, core=core, optional=optional,
ncol=ncol, text_width=text_width, sort=sort)
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ def test_report(capsys):
# We just ensure the shown packages do not change (core and optional).
out1 = scooby.Report(
core=['numpy', 'scipy', 'numba', 'empymod', 'libdlf'],
optional=['IPython', 'matplotlib'],
optional=['IPython', 'matplotlib', 'empygrad'],
ncol=3)
out2 = utils.Report()

Expand Down
Loading