[SciPy-user] In-place matrix reordering

Antonino Ingargiola tritemio@gmail....
Wed Feb 25 07:45:07 CST 2009


2009/2/25 Gael Varoquaux <gael.varoquaux@normalesup.org>:
> On Wed, Feb 25, 2009 at 11:31:25AM +0100, Antonino Ingargiola wrote:
>> Is there any workarounds to save ram in this case? Something like
>> using an external package or inline C (I have no idea about that).
>
> Save to a file. Delete the array, load the file using memmaping, and
> extract the components you are interested in to a memroy-resident array.

I saved the matrix with numpy.save, but I have a problem during the
assignment between the unordered (co) matrix and the reordered one
(cor). u is a sequence of indices with u.sahpe = (500,).

import numpy as N
co = N.memmap('S_co.npy', dtype='float64', shape=(288092, 500)
              # Raw data
cor = N.memmap('S_co_reord.npy', dtype='float64', shape=(288092, 500),
mode='w+') # Reordered data to be saved here
cor[:,:] = co[:,u]
Exception exceptions.AttributeError: "'memmap' object has no attribute
'_mmap'" in  ignored
---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)

/home/anto/Simulazioni/matlab/mc3d/<ipython console> in <module>()

MemoryError:

>>>

I've never used the N.memmap function so maybe I do something wrong
here. Any hints?

>
> Gaël

  ~ Antonio


More information about the SciPy-user mailing list