Skip to content

Commit

Permalink
examples: cleanup pytest imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Sep 12, 2024
1 parent 69fc6f2 commit 829ba37
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
5 changes: 0 additions & 5 deletions devito/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import atexit
from itertools import product
import os
from . import _version

import numpy as np

Expand Down Expand Up @@ -195,9 +194,5 @@ def mode_performance():
# job properly and thus we may end up missing some custom __del__'s
atexit.register(clear_cache)


__version__ = _version.get_versions()['version']


# Clean up namespace
del atexit, product
12 changes: 8 additions & 4 deletions devito/types/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,9 @@ def __init_finalize__(self, *args, **kwargs):

# Averaging mode for off the grid evaluation
self._avg_mode = kwargs.get('avg_mode', 'arithmetic')
assert self._avg_mode in ['arithmetic', 'harmonic'], "Accepted avg_mode " \
"values are 'arithmetic' or 'harmonic', invalid %s" % self._avg_mode
if self._avg_mode not in ['arithmetic', 'harmonic']:
raise ValueError("Invalid averaging mode_mode %s, accepted values are"
" arithmetic or harmonic" % self._avg_mode)

@classmethod
def __args_setup__(cls, *args, **kwargs):
Expand Down Expand Up @@ -1152,10 +1153,13 @@ def _evaluate(self, **kwargs):
return self

# Base function
retval = 1 / self.function if self._avg_mode == 'harmonic' else self.function
if self._avg_mode == 'harmonic':
retval = 1 / self.function
else:
retval = self.function
# Apply interpolation from inner most dim
for d, i in self._grid_map.items():
retval = retval.diff(d, deriv_order=0, fd_order=2, x0={d: i}).evaluate
retval = retval.diff(d, deriv_order=0, fd_order=2, x0={d: i})
if self._avg_mode == 'harmonic':
retval = 1 / retval

Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/acoustic/acoustic_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import pytest
except:
except ImportError:
pass

from devito.logger import info
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/elastic/elastic_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import pytest
except:
except ImportError:
pass
from devito import norm
from devito.logger import info
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/tti/tti_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import pytest
except:
except ImportError:
pass

from devito import Function, smooth, norm, info, Constant
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/viscoacoustic/viscoacoustic_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import pytest
except:
except ImportError:
pass

from devito.logger import info
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/viscoelastic/viscoelastic_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
try:
import pytest
except:
except ImportError:
pass

from devito import norm
Expand Down

0 comments on commit 829ba37

Please sign in to comment.