Skip to content

Bad handling of tensor names in unary negation operator #33938

@egourgoulhon

Description

@egourgoulhon

In Sage 9.7.beta1, we have

sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: a = M.vector_field(1, 2, name='a')
sage: b = M.vector_field(-y, x, name='b')
sage: c = -(a + b)
sage: c.display()
-a+b = (y - 1) ∂/∂x + (-x - 2) ∂/∂y

The left-hand side should be -(a+b), not -a+b.

The culprit is FreeModuleTensor.__neg__, as defined in line 2022 of src/sage/tensor/modules/free_module_tensor.py: it should invoke sage.tensor.modules.format_utilities.format_unop_txt to set up the output name.

Component: manifolds

Keywords: tensor, unary negation

Issue created by migration from https://trac.sagemath.org/ticket/33938

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions