bowman-lab / enspara

Modeling molecular ensembles with scalable data structures and parallel computing
https://enspara.readthedocs.io
GNU General Public License v3.0
33 stars 16 forks source link

RaggedArray third-dimension slice #164

Closed justinrporter closed 5 years ago

justinrporter commented 5 years ago

It appears not to be possible to calculate slice a stride in the third dimesion of a RaggedArray:

a = ra.RaggedArray(np.zeros((100, 2)), lengths=[90, 10])
a[:, :, ::2]

gives

ValueError                                Traceback (most recent call last)
<ipython-input-37-64bea6dd4686> in <module>()
      1 a = ra.RaggedArray(np.zeros((100, 2)), lengths=[90, 10])
----> 2 a[:, :, ::2]

~/modules/enspara/ra/ra.py in __getitem__(self, iis)
    531         # tuples get index conversion from 2d to 1d
    532         elif isinstance(iis, tuple):
--> 533             first_dimension, second_dimension = iis
    534             # if the first dimension is a slice, converts both sets of indices
    535             if isinstance(first_dimension, slice):

ValueError: too many values to unpack (expected 2)

@mizimmer90 is this a bug or expected behavior? It seems very reasonable to want to do this.

mizimmer90 commented 5 years ago

This is expected behavior. While it is reasonable to want this, the ragged array is currently only supported for 2 dimensions.