Skip to content

Commit

Permalink
Fix ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaversin committed Dec 3, 2024
1 parent 191e284 commit 934249d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions ufl/algorithms/formsplitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ def restricted(self, o):
expr = MultiFunction.reuse_if_untouched


def extract_blocks(form, i: Optional[int] = None, j: Optional[int] = None,
arity: Optional[int] = None):
def extract_blocks(
form, i: Optional[int] = None, j: Optional[int] = None, arity: Optional[int] = None
):
"""Extract blocks of a form.
If arity is 0, returns the form.
Expand All @@ -117,8 +118,8 @@ def extract_blocks(form, i: Optional[int] = None, j: Optional[int] = None,
arguments = form.arguments()

if arity is None:
numbers = tuple(sorted(set(a.number() for a in arguments)))
arity = len(numbers)
numbers = tuple(sorted(set(a.number() for a in arguments)))
arity = len(numbers)

assert arity <= 2
if arity == 0:
Expand Down
8 changes: 4 additions & 4 deletions ufl/algorithms/formtransformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ def compute_form_lhs(form):
form_blocks = extract_blocks(form, arity=2)
lhs = 0
for bi in form_blocks:
for bj in bi:
if bj is not None:
lhs += compute_form_with_arity(bj, 2)
for bj in bi:
if bj is not None:
lhs += compute_form_with_arity(bj, 2)
return lhs


Expand All @@ -378,7 +378,7 @@ def compute_form_rhs(form):
form_blocks = extract_blocks(form, arity=1)
rhs = 0
for bi in form_blocks:
rhs += compute_form_with_arity(bi, 1)
rhs += compute_form_with_arity(bi, 1)
return -rhs


Expand Down

0 comments on commit 934249d

Please sign in to comment.