For some reason the string representation of negative imaginary numbers in Python is different for equal values:
>>> str(-3j)
'(-0-3j)'
>>> str(0-3j)
'-3j'
Moreover, if I try to get the string representation of -0-3j
, I get:
>>> str(-0-3j)
'-3j'
Which seems like an inconsistency.
The problem is that I use the string representation of complex scalar tensors to compute the hash of some operators, and because of this inconsistency I get different hashes for equal operators.
Is there any way to convert '(-0-3j)'
to '-3j'
?
Edit:
Mechanic Pig pointed out that:
>>> str(-0.-3j)
'(-0-3j)'