It's doing the correct thing to the expression, but the result is not written in canonical form, and because of that displays incorrectly. What it's actually showing is
- \alpha_{-1}^{\mu} { -1 }^{1}
and because the curly brackets around the -1
do not show, you get this weird looking result.
The quickest way to fix this is to add an
expand_power(ex)
inside your bpz
function; that will turn (-1)^1
into (-1)
which then gets absorbed into product correctly. Using simplify(ex)
will also work, but is much slower and requires a roundtrip through sympy's simplify function.
It's a bug of course, I have registered it as https://github.com/kpeeters/cadabra2/issues/247.