Skip to content

Commit

Permalink
fix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Aug 8, 2023
1 parent 4e32e86 commit c93eaf5
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 27 deletions.
8 changes: 4 additions & 4 deletions test/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from ufl.algorithms import estimate_total_polynomial_degree
from ufl.algorithms.comparison_checker import do_comparison_check, ComplexComparisonError
from ufl.algorithms.formtransformations import compute_form_adjoint
from ufl import TestFunction, TrialFunction, triangle, FiniteElement, \
as_ufl, inner, grad, dx, dot, outer, conj, sqrt, sin, cosh, \
atan, ln, exp, as_tensor, real, imag, conditional, \
min_value, max_value, gt, lt, cos, ge, le, Coefficient
from ufl import (TestFunction, TrialFunction, triangle, FiniteElement,
as_ufl, inner, grad, dx, dot, outer, conj, sqrt, sin, cosh,
atan, ln, exp, as_tensor, real, imag, conditional,
min_value, max_value, gt, lt, cos, ge, le, Coefficient)


def test_conj(self):
Expand Down
8 changes: 4 additions & 4 deletions test/test_duals.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env py.test
# -*- coding: utf-8 -*-

from ufl import FiniteElement, FunctionSpace, MixedFunctionSpace, \
Coefficient, Matrix, Cofunction, FormSum, Argument, Coargument,\
TestFunction, TrialFunction, Adjoint, Action, \
action, adjoint, derivative, tetrahedron, triangle, interval, dx
from ufl import (FiniteElement, FunctionSpace, MixedFunctionSpace,
Coefficient, Matrix, Cofunction, FormSum, Argument, Coargument,
TestFunction, TrialFunction, Adjoint, Action,
action, adjoint, derivative, tetrahedron, triangle, interval, dx)
from ufl.constantvalue import Zero
from ufl.form import ZeroBaseForm

Expand Down
5 changes: 3 additions & 2 deletions test/test_new_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from ufl.classes import Grad
from ufl.algorithms import tree_format
from ufl.algorithms.renumbering import renumber_indices
from ufl.algorithms.apply_derivatives import apply_derivatives, GenericDerivativeRuleset, \
GradRuleset, VariableRuleset, GateauxDerivativeRuleset
from ufl.algorithms.apply_derivatives import (
apply_derivatives, GenericDerivativeRuleset,
GradRuleset, VariableRuleset, GateauxDerivativeRuleset)


# Note: the old tests in test_automatic_differentiation.py are a bit messy
Expand Down
3 changes: 1 addition & 2 deletions test/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from ufl import *

from ufl.classes import MultiIndex, FixedIndex
from ufl.algorithms.signature import compute_multiindex_hashdata, \
compute_terminal_hashdata
from ufl.algorithms.signature import compute_multiindex_hashdata, compute_terminal_hashdata

from itertools import chain

Expand Down
2 changes: 1 addition & 1 deletion ufl/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __eq__(self, other):
are the same ufl element but different dolfin function spaces.
"""
return (
type(self) == type(other) and self._number == other._number and # noqa: W504
type(self) is type(other) and self._number == other._number and # noqa: W504
self._part == other._part and self._ufl_function_space == other._ufl_function_space
)

Expand Down
2 changes: 1 addition & 1 deletion ufl/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def reconstruct(self, **kwargs: typing.Any) -> Cell:

def __lt__(self, other: AbstractCell) -> bool:
"""Define an arbitrarily chosen but fixed sort order for all cells."""
if type(self) == type(other):
if type(self) is type(other):
s = (self.geometric_dimension(), self.topological_dimension())
o = (other.geometric_dimension(), other.topological_dimension())
if s != o:
Expand Down
4 changes: 2 additions & 2 deletions ufl/core/ufl_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __hash__(self) -> int:
return hash(self._ufl_hash_data_())

def __eq__(self, other):
return type(self) == type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()
return type(self) is type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()

def __ne__(self, other):
return not self.__eq__(other)
Expand All @@ -61,7 +61,7 @@ def __hash__(self):

def __eq__(self, other):
"__eq__ implementation attached in attach_operators_from_hash_data"
return type(self) == type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()
return type(self) is type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()
cls.__eq__ = __eq__

def __ne__(self, other):
Expand Down
2 changes: 1 addition & 1 deletion ufl/exprequals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def expr_equals(self, other):

# Fast cutoffs for common cases, type difference or hash
# difference will cutoff more or less all nonequal types
if type(self) != type(other) or hash(self) != hash(other):
if type(self) is not type(other) or hash(self) != hash(other):
return False

# Large objects are costly to compare with themselves
Expand Down
2 changes: 1 addition & 1 deletion ufl/finiteelement/finiteelementbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __hash__(self):

def __eq__(self, other):
"Compute element equality for insertion in hashmaps."
return type(self) == type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()
return type(self) is type(other) and self._ufl_hash_data_() == other._ufl_hash_data_()

def __ne__(self, other):
"Compute element inequality for insertion in hashmaps."
Expand Down
15 changes: 8 additions & 7 deletions ufl/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
from ufl.form import Form
from ufl.constantvalue import Zero, RealValue, ComplexValue, as_ufl
from ufl.differentiation import VariableDerivative, Grad, Div, Curl, NablaGrad, NablaDiv
from ufl.tensoralgebra import Transposed, Inner, Outer, Dot, Cross, \
Determinant, Inverse, Cofactor, Trace, Deviatoric, Skew, Sym
from ufl.tensoralgebra import (
Transposed, Inner, Outer, Dot, Cross,
Determinant, Inverse, Cofactor, Trace, Deviatoric, Skew, Sym)
from ufl.coefficient import Coefficient
from ufl.variable import Variable
from ufl.tensors import as_tensor, as_matrix, as_vector, ListTensor
from ufl.conditional import EQ, NE, \
AndCondition, OrCondition, NotCondition, Conditional, MaxValue, MinValue
from ufl.conditional import (
EQ, NE, AndCondition, OrCondition, NotCondition, Conditional, MaxValue, MinValue)
from ufl.algebra import Conj, Real, Imag
from ufl.mathfunctions import Sqrt, Exp, Ln, Erf,\
Cos, Sin, Tan, Cosh, Sinh, Tanh, Acos, Asin, Atan, Atan2,\
BesselJ, BesselY, BesselI, BesselK
from ufl.mathfunctions import (
Sqrt, Exp, Ln, Erf, Cos, Sin, Tan, Cosh, Sinh, Tanh, Acos, Asin, Atan, Atan2,
BesselJ, BesselY, BesselI, BesselK)
from ufl.averaging import CellAvg, FacetAvg
from ufl.indexed import Indexed
from ufl.geometry import SpatialCoordinate, FacetNormal
Expand Down
5 changes: 3 additions & 2 deletions ufl/sobolevspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ def __init__(self, orders):
the position denotes in what spatial variable the
smoothness requirement is enforced.
"""
assert all(isinstance(x, int) or isinf(x) for x in orders), \
("Order must be an integer or infinity.")
assert all(
isinstance(x, int) or isinf(x)
for x in orders), "Order must be an integer or infinity."
name = "DirectionalH"
parents = [L2]
super(DirectionalSobolevSpace, self).__init__(name, parents)
Expand Down

0 comments on commit c93eaf5

Please sign in to comment.