[SciPy-user] npfile deprecated?

Steve Schmerler elcorto@gmx....
Thu Oct 16 07:15:07 CDT 2008

On Oct 15 17:49 -0500, Robert Kern  wrote:
> What functionality do you think that npfile provided which
> tofile()/fromfile() doesn't? npfile never wrote out header
> information. The files were always just the raw platform-specific
> binary bytes. It's API is somewhat more convenient (you can specify
> the shape in the method call rather than modifying it later), but
> that's about it.

Well ok, it's mostly only the API rather than functionallity.

I suppose that with tofile/fromfile, I could use approximately this
    >>> sys.byteorder
    >>> sh = (3,5)
    >>> ord = 'F'
    >>> a = asarray(np.ramdom.random(sh), order=ord)
    >>> dt = a.dtype
    >>> a.tofile('test.dat')

and on another machine
    >>> a = fromfile('test.dat', dtype=dt).reshape(sh)
    >>> a = asarray(a, order='F')
    >>> if sys.byteorder == 'big': a = a.byteswap()

Here, and in the npfile case, one would use wrappers writing and reading
metainfos (dtype, order, byteorder and shape) to and from an extra file
(at least, I did this).

The only functionallity difference is that files on disk would be always
in C-order. 

Anyway, god bless numpy.save() :-)


More information about the SciPy-user mailing list