From: <jo...@st...> - 2006-05-20 22:14:07
|
For your information: I just created a small cookbook document http://scipy.org/Cookbook/InputOutput where it is explained how one can read and write Numpy arrays in human readable (ascii) format. The document describes how one can use read_array/write_array if SciPy is installed, or how one can use load/save if Matplotlib is installed. When neither of these two packages is installed, one basically has no other choice then to improvise, so I also give here a few examples how one could do this. Imho, there is something unsatisfactorily about this need to improvise. Ascii input/output of numpy arrays seems to me a very basic need. Even when one defines Numpy crudely as the N-dimensional array object, and Scipy as the science you can do with these array objects, then I would intuitively still expect that ascii input/output would belong to Numpy rather than to Scipy. There are Numpy support functions for binary format, and for pickled format, but strangely enough not really for ascii format. tofile() and fromfile() do not preserve the shape of a 2d array, and are in practice therefore hardly usable. There may be a signficant fraction of Numpy users that do not need SciPy for their work, and have only Numpy installed. My guess is that the read_array and write_array functions have already been re-invented many many times by these users. Imho, I therefore think that Numpy deserves its own read_array/write_array method. Does anyone else have this feeling, or am I the only one? :o) Joris Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |