Skip to content

Commit

Permalink
docs: flake8 and others
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Sep 8, 2023
1 parent d62e340 commit dea361c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
21 changes: 9 additions & 12 deletions devito/ir/support/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,27 +425,24 @@ def distance(self, other):
ret.append(S.Zero)
else:
v = i - j
# If (i-j) is a finite number, then we potentially have an Imaginary dependence
if v.is_Number and v.is_finite:
# If i and j are numbers, we append an (I) distance
if i.is_Number and j.is_Number:
return Vector(S.ImaginaryUnit)
# If i and j are not numbers, there may be dimension-dependent dependencies
# so we append the distance
# If both i and j are not numbers, there may be dimension-dependent
# dependencies so we append the distance
else:
ret.append(v)

# We are writing over an entire dimension but reading from one point.
# If there are overlaps between the two then we would have a dependency
# This is a conservative estimation as there are cases (example below) where
# we potentially don't actually have a dependency given that we don't write
# over the entire dimension
# But we would need the exact iteration intervals to compute this,
# which is only known at compile time

# No Dependency Example:
# Eq(u[0,y], 1)
# Eq(u[1, y+1], u[0,1])
# This is a conservative estimation as there are cases (example below)
# where we may or may not have a dependency given that we don't write
# depending on domain size, which is not compilation-time known

# For example:
# Eq(u[0, y], 1)
# Eq(u[1, y+1], u[0, 1])
elif i.is_Number and not j.is_Number:
ret.append(S.Infinity)

Expand Down
13 changes: 6 additions & 7 deletions tests/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,11 @@ def test_2194(self):
op = Operator([eq_1, eq_3])
op.apply()

expected = np.array([[ 1., 1., 1.],
expected = np.array([[1., 1., 1.],
[-1., 0., -1.]])

assert(np.all(u.data[:] == expected[:]))


@pytest.mark.parametrize('eqns', [
['Eq(u0[0, y], 1)', 'Eq(u0[1, y], u0[0, y + 1])'],
])
Expand Down Expand Up @@ -874,12 +873,12 @@ def test_2194_v3(self):
eq1 = Eq(u[1, y], u[0, 2])

op = Operator([eq0, eq1])
op.apply()
op.apply()

expected = np.array([[1., 1., 1.],
[1., 1., 1.],
[0., 0., 0.]])

expected = np.array([[1.,1.,1.],
[1.,1.,1.],
[0.,0.,0.]])

assert(np.all(u.data[:] == expected[:]))


Expand Down

0 comments on commit dea361c

Please sign in to comment.