[SciPy-user] numpy.compress and sparse matrices?

Marco Lui saffsd@gmail....
Tue Jun 9 09:11:05 CDT 2009

Hello everyone.

I am looking for a sparse matrix implementation that supports the
numpy.compress operation, which is akin to "fancy indexing" by a boolean
vector. Working in scipy 0.6.0, I have not been able to find such an
implementation. I usually get an error like the following:

  File "/home/mlui/workspace/sparse/modules/hydrat/task/task.py", line 59,
in train_vectors
    return numpy.compress(self.train_indices, data, axis=0)
  File "/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.py", line
794, in compress
    return _wrapit(a, 'compress', condition, axis, out)
  File "/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.py", line
37, in _wrapit
    result = getattr(asarray(obj),method)(*args, **kwds)
IndexError: index out of range for array

The above example works correctly when data is a normal numpy array. Does
any implementation of sparse arrays compatible with numpy.compress exist?

Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090610/3f33171f/attachment-0001.html 

More information about the SciPy-user mailing list