I have a string
s = "[0. -0.002j,-0.002-0.002j,-0.003+0.j ],\n[0.01+0.j , 0.001-0.001j,-0. +0.0009j]]"
And I'd like to convet this to np.array. Using np.fromstring np.loadtxt and using JSON as an intermediate step all have problems with complex numbers (and it's even worse with comma separation.
This type of output is generated by np.array2string(x,separator=',').
What would be elegant/concise/canonical way of doing this conversion?
Initial missing bracket is a typo, keeping original statement of the question so that answers make more sense.
np.array(eval('[' + s.replace('\n','')))repr(x.tolist())would be safer. Better yet apickle.dumps.