Skip to content

Commit

Permalink
ci: new flake8 version fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Aug 24, 2023
1 parent 1aa35df commit d7d2040
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 28 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ jobs:
- name: Tests in examples
run: |
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/acoustic/acoustic_example.py
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/viscoacoustic/viscoacoustic_example.py
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/tti/tti_example.py
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/elastic/elastic_example.py
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/viscoelastic/viscoelastic_example.py
- name: Seismic acoustic examples
run: |
Expand Down
9 changes: 0 additions & 9 deletions devito/passes/iet/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ def _drop_halospots(iet):
if f in hs.fmapper and all(i.is_reduction for i in v):
mapper[hs].add(f)

# If a HaloSpot is outside any iteration it is not needed
for iters, halo_spots in MapNodes(Iteration, HaloSpot, 'groupby').visit(iet).items():
if iters:
continue
for hs in halo_spots:
for f, v in hs.fmapper.items():
if v.loc_indices:
mapper[hs].add(f)

# Transform the IET introducing the "reduced" HaloSpots
subs = {hs: hs._rebuild(halo_scheme=hs.halo_scheme.drop(mapper[hs]))
for hs in FindNodes(HaloSpot).visit(iet)}
Expand Down
2 changes: 2 additions & 0 deletions devito/passes/iet/parpragma.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def _select_candidates(self, candidates):
except TypeError:
pass

# At least one inner loop (nested) or
# we do not collapse most inner loop if it is an atomic reduction
if not i.is_ParallelAtomic or nested:
collapsable.append(i)

Expand Down
4 changes: 2 additions & 2 deletions devito/symbolics/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ def has_integer_args(*args):

def sympy_dtype(expr, default):
"""
Try to infer the data type of the expression
returns the default if non is found
Infer the dtype of the expression
or default if could not be determined.
"""
# Symbol/... without argument, check its dtype
if len(expr.args) == 0:
Expand Down
2 changes: 1 addition & 1 deletion devito/types/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def __new__(cls, *args, **kwargs):
# Go straight through Basic, thus bypassing caching and machinery
# in sympy.Application/Function that isn't really necessary
# AbstractFunctions are unique by construction!
newobj = sympy.Basic.__new__(cls, *indices)
newobj = sympy.Basic.__new__(cls, *sympy.sympify(indices))

# Initialization. The following attributes must be available
# when executing __init_finalize__
Expand Down
10 changes: 9 additions & 1 deletion devito/types/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def indirect(self):

@property
def index(self):
return self if self.indirect is True else getattr(self, 'parent', self)
return self

@property
def is_const(self):
Expand Down Expand Up @@ -477,6 +477,10 @@ def __init_finalize__(self, name, parent):
def parent(self):
return self._parent

@property
def index(self):
return self if self.indirect else self.parent

@property
def root(self):
return self._parent.root
Expand Down Expand Up @@ -1228,6 +1232,10 @@ def is_Derived(self):
def parent(self):
return self._parent

@property
def index(self):
return self.parent or self

@property
def root(self):
if self.is_Derived:
Expand Down
18 changes: 14 additions & 4 deletions devito/types/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __subfunc_setup__(self, key, suffix, dtype=None):
# Fallback to default behaviour
dtype = dtype or self.dtype
else:
if not isinstance(key, np.ndarray):
if key is not None:
key = np.array(key)

if (shape != key.shape[:2] and key.shape != (shape[1],)) and \
Expand Down Expand Up @@ -197,6 +197,16 @@ def _dist_datamap(self):
def npoint(self):
return self.shape[self._sparse_position]

@property
def npoint_global(self):
"""
Global `npoint`s. This only differs from `self.npoint` in an MPI context.
Issues
------
* https://github.com/devitocodes/devito/issues/1498
"""
return self._npoint

@property
def space_order(self):
"""The space order."""
Expand Down Expand Up @@ -1656,9 +1666,9 @@ def __indices_setup__(cls, *args, **kwargs):
"""
Return the default Dimension indices for a given data shape.
"""
Dimensions = kwargs.get('dimensions')
if Dimensions is None:
Dimensions = (kwargs['grid'].time_dim, Dimension(
dimensions = kwargs.get('dimensions')
if dimensions is None:
dimensions = (kwargs['grid'].time_dim, Dimension(
name='p_%s' % kwargs["name"]))

if args:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,9 @@ def test_sparse_function(self, operate_on_empty_cache):

i = u.inject(expr=u, field=u)

# created: rxu, rxy (radius dimensions) and spacings and conditionals
# conditional sparse dim
# created: rux, ruy (radius dimensions) and spacings
# posx, posy, px, py, u_coords (as indexified),
ncreated = 2+2+1+2+2+2+1
ncreated = 2+1+2+2+2+1
# Note that injection is now lazy so no new symbols should be created
assert len(_SymbolCache) == cur_cache_size
i.evaluate
Expand All @@ -661,7 +660,7 @@ def test_sparse_function(self, operate_on_empty_cache):
# in the first clear_cache they were still referenced by their "parent" objects
# (e.g., ru* by ConditionalDimensions, through `condition`)

assert len(_SymbolCache) == init_cache_size + 10
assert len(_SymbolCache) == init_cache_size + 8
clear_cache()
# Now we should be back to the original state except for
# pos* that belong to the abstract class
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gpu_openacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def test_multiple_tile_sizes(self, par_tile):
trees = retrieve_iteration_tree(op)
assert len(trees) == 4

assert trees[1][1].pragmas[0].value ==\
assert trees[0][1].pragmas[0].value ==\
'acc parallel loop tile(32,4,4) present(u)'
assert trees[2][1].pragmas[0].value ==\
assert trees[1][1].pragmas[0].value ==\
'acc parallel loop tile(8,8) present(u)'

def test_multi_tile_blocking_structure(self):
Expand Down

0 comments on commit d7d2040

Please sign in to comment.