diff --git a/test/test_duals.py b/test/test_duals.py index 7786e7400..909538d49 100644 --- a/test/test_duals.py +++ b/test/test_duals.py @@ -121,6 +121,9 @@ def test_addition(): V = FunctionSpace(domain_2d, f_2d) V_dual = V.dual() + fvector_2d = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1) + W = FunctionSpace(domain_2d, fvector_2d) + u = TrialFunction(V) v = TestFunction(V) @@ -152,6 +155,11 @@ def test_addition(): res -= ZeroBaseForm((v,)) assert res == L + # Simplification with respect to ufl.Zero + a_W = Matrix(W, W) + res = a_W + Zero(W.value_shape) + assert res == a_W + def test_scalar_mult(): domain_2d = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)) diff --git a/ufl/__init__.py b/ufl/__init__.py index e2656a76b..9d255211a 100644 --- a/ufl/__init__.py +++ b/ufl/__init__.py @@ -44,147 +44,147 @@ * Cells:: - - AbstractCell - - Cell - - TensorProductCell - - vertex - - interval - - triangle - - tetrahedron - - quadrilateral - - hexahedron - - prism - - pyramid - - pentatope - - tesseract + -AbstractCell + -Cell + -TensorProductCell + -vertex + -interval + -triangle + -tetrahedron + -quadrilateral + -hexahedron + -prism + -pyramid + -pentatope + -tesseract * Domains:: - - AbstractDomain - - Mesh - - MeshView + -AbstractDomain + -Mesh + -MeshView * Sobolev spaces:: - - L2 - - H1 - - H2 - - HInf - - HDiv - - HCurl - - HEin - - HDivDiv + -L2 + -H1 + -H2 + -HInf + -HDiv + -HCurl + -HEin + -HDivDiv * Pull backs:: - - identity_pullback - - contravariant_piola - - covariant_piola - - l2_piola - - double_contravariant_piola - - double_covariant_piola + -identity_pullback + -contravariant_piola + -covariant_piola + -l2_piola + -double_contravariant_piola + -double_covariant_piola * Function spaces:: - - FunctionSpace - - MixedFunctionSpace + -FunctionSpace + -MixedFunctionSpace * Arguments:: - - Argument - - TestFunction - - TrialFunction - - Arguments - - TestFunctions - - TrialFunctions + -Argument + -TestFunction + -TrialFunction + -Arguments + -TestFunctions + -TrialFunctions * Coefficients:: - - Coefficient - - Constant - - VectorConstant - - TensorConstant + -Coefficient + -Constant + -VectorConstant + -TensorConstant * Splitting form arguments in mixed spaces:: - - split + -split * Literal constants:: - - Identity - - PermutationSymbol + -Identity + -PermutationSymbol * Geometric quantities:: - - SpatialCoordinate - - FacetNormal - - CellNormal - - CellVolume - - CellDiameter - - Circumradius - - MinCellEdgeLength - - MaxCellEdgeLength - - FacetArea - - MinFacetEdgeLength - - MaxFacetEdgeLength - - Jacobian - - JacobianDeterminant - - JacobianInverse + -SpatialCoordinate + -FacetNormal + -CellNormal + -CellVolume + -CellDiameter + -Circumradius + -MinCellEdgeLength + -MaxCellEdgeLength + -FacetArea + -MinFacetEdgeLength + -MaxFacetEdgeLength + -Jacobian + -JacobianDeterminant + -JacobianInverse * Indices:: - - Index - - indices - - i, j, k, l - - p, q, r, s + -Index + -indices + -i, j, k, l + -p, q, r, s * Scalar to tensor expression conversion:: - - as_tensor - - as_vector - - as_matrix + -as_tensor + -as_vector + -as_matrix * Unit vectors and matrices:: - - unit_vector - - unit_vectors - - unit_matrix - - unit_matrices + -unit_vector + -unit_vectors + -unit_matrix + -unit_matrices * Tensor algebra operators:: - - outer, inner, dot, cross, perp - - det, inv, cofac - - transpose, tr, diag, diag_vector - - dev, skew, sym + -outer, inner, dot, cross, perp + -det, inv, cofac + -transpose, tr, diag, diag_vector + -dev, skew, sym * Elementwise tensor operators:: - - elem_mult - - elem_div - - elem_pow - - elem_op + -elem_mult + -elem_div + -elem_pow + -elem_op * Differential operators:: - - variable - - diff, - - grad, nabla_grad - - div, nabla_div - - curl, rot - - Dx, Dn + -variable + (-diff,) + -grad, nabla_grad + -div, nabla_div + -curl, rot + -Dx, Dn * Nonlinear functions:: - - max_value, min_value - - abs, sign - - sqrt - - exp, ln, erf - - cos, sin, tan - - acos, asin, atan, atan2 - - cosh, sinh, tanh - - bessel_J, bessel_Y, bessel_I, bessel_K + -max_value, min_value + -abs, sign + -sqrt + -exp, ln, erf + -cos, sin, tan + -acos, asin, atan, atan2 + -cosh, sinh, tanh + -bessel_J, bessel_Y, bessel_I, bessel_K * Complex operations:: @@ -193,10 +193,10 @@ * Discontinuous Galerkin operators:: - - v('+'), v('-') - - jump - - avg - - cell_avg, facet_avg + -v("+"), v("-") + -jump + -avg + -cell_avg, facet_avg * Conditional operators:: @@ -207,21 +207,21 @@ * Integral measures:: - - dx, ds, dS, dP - - dc, dC, dO, dI, dX - - ds_b, ds_t, ds_tb, ds_v, dS_h, dS_v + -dx, ds, dS, dP + -dc, dC, dO, dI, dX + -ds_b, ds_t, ds_tb, ds_v, dS_h, dS_v * Form transformations:: - - rhs, lhs - - system - - functional - - replace - - adjoint - - action - - energy_norm, - - sensitivity_rhs - - derivative + -rhs, lhs + -system + -functional + -replace + -adjoint + -action + (-energy_norm,) + -sensitivity_rhs + -derivative """ # Copyright (C) 2008-2016 Martin Sandve Alnæs and Anders Logg diff --git a/ufl/algorithms/__init__.py b/ufl/algorithms/__init__.py index a2ca0ebb7..18dce39fd 100644 --- a/ufl/algorithms/__init__.py +++ b/ufl/algorithms/__init__.py @@ -14,7 +14,6 @@ # recommended to use. The __all__ list below is a start based # on grepping of other FEniCS code for ufl.algorithm imports. - __all__ = [ "estimate_total_polynomial_degree", "sort_elements", diff --git a/ufl/algorithms/apply_restrictions.py b/ufl/algorithms/apply_restrictions.py index b8c049ab7..a7550d722 100644 --- a/ufl/algorithms/apply_restrictions.py +++ b/ufl/algorithms/apply_restrictions.py @@ -10,7 +10,6 @@ # # SPDX-License-Identifier: LGPL-3.0-or-later - from ufl.algorithms.map_integrands import map_integrand_dags from ufl.classes import Restricted from ufl.corealg.map_dag import map_expr_dag diff --git a/ufl/algorithms/check_arities.py b/ufl/algorithms/check_arities.py index 12a7e53c1..dc255b7bc 100644 --- a/ufl/algorithms/check_arities.py +++ b/ufl/algorithms/check_arities.py @@ -1,4 +1,5 @@ """Check arities.""" + from itertools import chain from ufl.classes import Argument, Zero diff --git a/ufl/compound_expressions.py b/ufl/compound_expressions.py index 840397caa..6f92dd00d 100644 --- a/ufl/compound_expressions.py +++ b/ufl/compound_expressions.py @@ -7,7 +7,6 @@ # # Modified by Anders Logg, 2009-2010 - from ufl.constantvalue import Zero, zero from ufl.core.multiindex import Index, indices from ufl.operators import sqrt diff --git a/ufl/core/multiindex.py b/ufl/core/multiindex.py index 523d21d20..2d91e40f3 100644 --- a/ufl/core/multiindex.py +++ b/ufl/core/multiindex.py @@ -8,7 +8,6 @@ # # Modified by Massimiliano Leoni, 2016. - from ufl.core.terminal import Terminal from ufl.core.ufl_type import ufl_type from ufl.utils.counted import Counted diff --git a/ufl/form.py b/ufl/form.py index 34aa3d753..1f4b1a20d 100644 --- a/ufl/form.py +++ b/ufl/form.py @@ -142,7 +142,7 @@ def __add__(self, other): if isinstance(other, (int, float)) and other == 0: # Allow adding 0 or 0.0 as a no-op, needed for sum([a,b]) return self - elif isinstance(other, Zero) and not (other.ufl_shape or other.ufl_free_indices): + elif isinstance(other, Zero): # Allow adding ufl Zero as a no-op, needed for sum([a,b]) return self diff --git a/ufl/formatting/ufl2unicode.py b/ufl/formatting/ufl2unicode.py index 0ed83ed1c..04956f137 100644 --- a/ufl/formatting/ufl2unicode.py +++ b/ufl/formatting/ufl2unicode.py @@ -196,7 +196,7 @@ class UC: left_double_angled_bracket = "⟪" right_double_angled_bracket = "⟫" - combining_right_arrow_above = "\u20D7" + combining_right_arrow_above = "\u20d7" combining_overline = "\u0305" diff --git a/ufl/indexsum.py b/ufl/indexsum.py index df636b58c..38b0e1cce 100644 --- a/ufl/indexsum.py +++ b/ufl/indexsum.py @@ -6,7 +6,6 @@ # # SPDX-License-Identifier: LGPL-3.0-or-later - from ufl.constantvalue import Zero from ufl.core.expr import Expr, ufl_err_str from ufl.core.multiindex import MultiIndex