[Nipy-devel] good format for storing numeric data
Thu Nov 26 11:27:50 CST 2009
On Thu, Nov 26, 2009 at 12:12:47PM -0500, Satrajit Ghosh wrote:
> > To make install painless, you also have a pure Python reader:
> > http://h5py.alfven.org/
> that's what i'm using. it requires underlying hdf5 libraries, which
> were a little bit of a pain to install on 64-bit snow leopard.
> however, on windows h5py includes the hdf5 libraries.
Ha; good to know. I wasn't aware of that.
> related to matlab's load function, is there a way i can write
> something that will initialize these variables in the workspace. so
> when i do myload('myfile.npz') without an lhs assignment i will get a
> variable named 'foo' in my workspace?
No. What you are talking about is modify the local scope by injecting
variables in it (or the global scope, even worse). From a coding
perspective, this is horrible. It renders any static analysis tools
useless and can create crazy side effects.
What you can do, is simply use your code, with the bunch pattern
(http://code.activestate.com/recipes/52308/) to create a namespace. You
would get code like:
ns = my_load('my_file.npy')
If you want to do this interactively, to save you 'workspace', and not
while coding (which is than, IMHO, no longer a hack, but a useful
functionnality), you can use '%store' under IPython. (it doesn't really
do what you want).
There is also Mike McKerns' dill pickle replacement, which is more
experimental, but fairly impressive. It can pickle a full interpreter
Use dump_session/load_session. I am not sure it will work under IPython
because of magic IPython does with the main module.
More information about the Nipy-devel