I can't understand why this formatter doesn't format a complex128
:
import numpy as np
import scipy.sparse as sp
A = sp.diags([1, -2, 1], [1, 0, -1], shape=[3, 3], format='csc')
evals, evecs = sp.linalg.eigs(A, k=1, which='LM')
with np.printoptions(formatter={'complex_kind': '{:.2f}'.format}):
print (evals, evals[0])
This code displays a one-element numpy.ndarray, then the element. The formatter is used for the array, not for the element alone:
[-3.41+0.00j] (-3.4142135623730954+0j)
Types involved:
type(evals): numpy.ndarray
evals.dtype: dtype('complex128')
type(evals[0]): numpy.complex128
Any clue appreciated.