Undo Pretty Print From Numpy
Solution 1:
You need fromstring(S, sep=' ')
. You almost parsed the string as packed binary data instead of printable floats. The string should only contain numbers and the delimiter (space), so trim it to get rid of the brackets. E.g., S[1:-1]
.
You probably know this but let's spell it out: This may be handy for recovering the results of a computation (or recovering from a mistake), but it is not a good way to store and reload data. It is inconvenient and you lose precision in the conversion. Your functions should return an array instead of printing it out, and if you need to store data for use by a later program run, use a digital storage format (e.g., see the cPickle
module or whatever numpy provides for the purpose-- note that fromstring can also read packed binary data)
Post a Comment for "Undo Pretty Print From Numpy"