weld-project / weld

High-performance runtime for data analytics applications
https://www.weld.rs
BSD 3-Clause "New" or "Revised" License
2.99k stars 257 forks source link

iter with negative step #426

Open radujica opened 5 years ago

radujica commented 5 years ago

The intent is to reverse a string, i.e. a vec[i8], however iter with negative step seems to be broken (at least on the master branch). Take the following examples:

np.array([1, 2, 3, 4, 5, 6, 7])  # data ~ _inp0: vec[i64]

result(for(iter(_inp0, 1L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// returns [2] = CORRECT
result(for(iter(_inp0, 2L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// returns [<some random number>, <some random number>] = RUBBISH
same for start = 3, 4, 5 returning list of 3, 4, 5 random numbers, respectively

result(for(iter(_inp0, 6L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// throws BadIteratorLength, despite 6 being a valid index for the last value

Some checks:

result(for(iter(_inp0, 0L, 7L, 1L), appender, |b, i, e| merge(b, e)))
// returns the same array, so return type or encoding is not broken

// removing vectorize pass (throwback to a previous issue) does NOT solve this