Closed stevenrbrandt closed 3 years ago
@stevenrbrandt How can I reproduce this?
It seems columns was set to columns: list(nil, 11)
Still trying to figure out why.
The error seems to be triggered here: features = idx[asrt][:n_features]
. So it like nil should be valid and should get interpreted as 0.
Supplying the zero does not help. Apparently, I can't use a slice there.
A smaller version of the problem:
from phylanx import Phylanx
import numpy as np
@Phylanx
def foo2():
arr = hstack(list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29))
inds = list(14, 18, 19, 20, 23, 26, 5, 29, 21, 8, 7, 28, 16, 22, 25, 2, 13,
24, 1, 11, 4, 12, 15, 27, 0, 17, 9, 3, 6, 10)
print(arr[inds][0:11])
foo2()
So it appears using a long list of indexes to get a slice isn't a supported feature in Phylanx. If you leave off the [0:11]
it gives a proper error. That's probably what ought to happen when the [0:11]
is supplied as well.
So it appears using a long list of indexes to get a slice isn't a supported feature in Phylanx. If you leave off the
[0:11]
it gives a proper error. That's probably what ought to happen when the[0:11]
is supplied as well.
@stevenrbrandt FWIW, this happens even for small lists of indices.
@hkaiser but not if the list is of size 2, then it's interpreted as a range.
@hkaiser but not if the list is of size 2, then it's interpreted as a range.
Yes, Phylanx understands arrays of integer indices for indirect indexing:
from phylanx import Phylanx
import numpy as np
@Phylanx
def foo():
arr = np.array([0, 1, 2, 3, 4])
inds = np.array([2, 1, 3, 4])
return arr[inds][0:2]
result = foo()
print(result) # should print `2 1`
and it uses list(...)
as an equivalent for Python's range type, i.e. arr[start:stop:step]
is expressed as slice(arr, list(start, stop, step))
.