Skip to content

Commit

Permalink
test: add test for 0**{min_value, max_value}
Browse files Browse the repository at this point in the history
  • Loading branch information
ksagiyam committed Nov 11, 2024
1 parent 357ddf2 commit 8b9c8ec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/regression/test_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,12 @@ def test_assemble_sparsity_diagonal_entries_for_bc():
A = assemble(inner(u[1], v[0]) * dx, bcs=[bc], mat_type="nest")
# Make sure that diagonals are allocated.
assert np.all(A.M.sparsity[1][1].nnz == np.ones(4, dtype=IntType))


def test_assemble_power_zero_minmax():
mesh = UnitSquareMesh(1, 1)
V = FunctionSpace(mesh, "CG", 1)
f = Function(V).assign(1.)
g = Function(V).assign(2.)
assert assemble(zero()**min_value(f, g) * dx) == 0.0

Check failure on line 326 in tests/regression/test_assemble.py

View workflow job for this annotation

GitHub Actions / Firedrake complex

test_assemble.test_assemble_power_zero_minmax

ufl.algorithms.comparison_checker.ComplexComparisonError: You can't compare complex numbers with min.
Raw output
def test_assemble_power_zero_minmax():
        mesh = UnitSquareMesh(1, 1)
        V = FunctionSpace(mesh, "CG", 1)
        f = Function(V).assign(1.)
        g = Function(V).assign(2.)
>       assert assemble(zero()**min_value(f, g) * dx) == 0.0

tests/regression/test_assemble.py:326: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
petsc4py/PETSc/Log.pyx:188: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
    ???
petsc4py/PETSc/Log.pyx:189: in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
    ???
firedrake/adjoint_utils/assembly.py:28: in wrapper
    form = BaseFormAssembler.preprocess_base_form(form)
firedrake/assemble.py:820: in preprocess_base_form
    expr = BaseFormAssembler.expand_derivatives_form(expr, form_compiler_parameters)
firedrake/assemble.py:858: in expand_derivatives_form
    return ufl.algorithms.preprocess_form(form, complex_mode)
../firedrake_venv/src/ufl/ufl/algorithms/compute_form_data.py:224: in preprocess_form
    form = do_comparison_check(form)
../firedrake_venv/src/ufl/ufl/algorithms/comparison_checker.py:140: in do_comparison_check
    return map_integrand_dags(CheckComparisons(), form)
../firedrake_venv/src/ufl/ufl/algorithms/map_integrands.py:73: in map_integrand_dags
    return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
../firedrake_venv/src/ufl/ufl/algorithms/map_integrands.py:25: in map_integrands
    mapped_integrals = [map_integrands(function, itg, only_integral_type)
../firedrake_venv/src/ufl/ufl/algorithms/map_integrands.py:33: in map_integrands
    return itg.reconstruct(function(itg.integrand()))
../firedrake_venv/src/ufl/ufl/algorithms/map_integrands.py:73: in <lambda>
    return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
../firedrake_venv/src/ufl/ufl/corealg/map_dag.py:34: in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress,
../firedrake_venv/src/ufl/ufl/corealg/map_dag.py:100: in map_expr_dags
    r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ufl.algorithms.comparison_checker.CheckComparisons object at 0x7f2b25af99a0>
o = MinValue(Coefficient(WithGeometry(FunctionSpace(<firedrake.mesh.MeshTopology object at 0x7f2b25bebfb0>, FiniteElement(...Lagrange', triangle, 1), name=None), Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 5418)), 10819))
ops = (Coefficient(WithGeometry(FunctionSpace(<firedrake.mesh.MeshTopology object at 0x7f2b25bebfb0>, FiniteElement('Lagrang...Lagrange', triangle, 1), name=None), Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 5418)), 10819))
types = {'complex'}

    def min_value(self, o, *ops):
        """Apply to min_value."""
        types = {self.nodetype[op] for op in ops}
    
        if "complex" in types:
>           raise ComplexComparisonError("You can't compare complex numbers with min.")
E           ufl.algorithms.comparison_checker.ComplexComparisonError: You can't compare complex numbers with min.

../firedrake_venv/src/ufl/ufl/algorithms/comparison_checker.py:77: ComplexComparisonError
assert assemble(zero()**max_value(f, g) * dx) == 0.0

0 comments on commit 8b9c8ec

Please sign in to comment.