internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: open-mmlab/mmaction2

Issue:
Seed in sampler
https://github.com/open-mmlab/mmdetection/pull/4665


Discussion:

Resolving patch:
diff --git a/mmaction/datasets/builder.py b/mmaction/datasets/builder.py
--- a/mmaction/datasets/builder.py
+++ b/mmaction/datasets/builder.py
@@ -84,10 +84,11 @@ def build_dataloader(dataset,
     if dist:
         if sample_by_class:
             assert power is not None
-            sampler = DistributedPowerSampler(dataset, world_size, rank, power)
+            sampler = DistributedPowerSampler(
+                dataset, world_size, rank, power, seed=seed)
         else:
             sampler = DistributedSampler(
-                dataset, world_size, rank, shuffle=shuffle)
+                dataset, world_size, rank, shuffle=shuffle, seed=seed)
         shuffle = False
         batch_size = videos_per_gpu
         num_workers = workers_per_gpu
diff --git a/mmaction/datasets/samplers/distributed_sampler.py b/mmaction/datasets/samplers/distributed_sampler.py
--- a/mmaction/datasets/samplers/distributed_sampler.py
+++ b/mmaction/datasets/samplers/distributed_sampler.py
@@ -10,15 +10,22 @@ class DistributedSampler(_DistributedSampler):
     class will port one to DistributedSampler.
     """
 
-    def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True):
-        super().__init__(dataset, num_replicas=num_replicas, rank=rank)
-        self.shuffle = shuffle
+    def __init__(self,
+                 dataset,
+                 num_replicas=None,
+                 rank=None,
+                 shuffle=True,
+                 seed=0):
+        super().__init__(
+            dataset, num_replicas=num_replicas, rank=rank, shuffle=shuffle)
+        # for the compatibility from PyTorch 1.3+
+        self.seed = seed if seed is not None else 0
 
     def __iter__(self):
         # deterministically shuffle based on epoch
         if self.shuffle:
             g = torch.Generator()
-            g.manual_seed(self.epoch)
+            g.manual_seed(self.epoch + self.seed)
             indices = torch.randperm(len(self.dataset), generator=g).tolist()
         else:
             indices = torch.arange(len(self.dataset)).tolist()
@@ -45,14 +52,15 @@ class DistributedPowerSampler(_DistributedSampler):
     from the entire dataset.
     """
 
-    def __init__(self, dataset, num_replicas=None, rank=None, power=1):
+    def __init__(self, dataset, num_replicas=None, rank=None, power=1, seed=0):
         super().__init__(dataset, num_replicas=num_replicas, rank=rank)
         self.power = power
+        self.seed = seed if seed is not None else 0
 
     def __iter__(self):
         # deterministically shuffle based on epoch
         g = torch.Generator()
-        g.manual_seed(self.epoch)
+        g.manual_seed(self.epoch + self.seed)
         video_infos_by_class = self.dataset.video_infos_by_class
         num_classes = self.dataset.num_classes
         # For simplicity, discontinuous labels are not permitted


Test patch:
Repository: open-mmlab/mmaction2

Issue:
Wrong Value for flow normalization
`img_norm_cfg` should be `dict(mean=[128, 128], std=[128,128])`, not imagenet one.


Discussion:

Resolving patch:
diff --git a/configs/recognition/tsn/tsn_r50_320p_1x1x3_110e_kinetics400_flow.py b/configs/recognition/tsn/tsn_r50_320p_1x1x3_110e_kinetics400_flow.py
--- a/configs/recognition/tsn/tsn_r50_320p_1x1x3_110e_kinetics400_flow.py
+++ b/configs/recognition/tsn/tsn_r50_320p_1x1x3_110e_kinetics400_flow.py
@@ -7,8 +7,7 @@
 ann_file_train = 'data/kinetics400/kinetics_flow_train_list.txt'
 ann_file_val = 'data/kinetics400/kinetics_flow_val_list.txt'
 ann_file_test = 'data/kinetics400/kinetics_flow_val_list.txt'
-img_norm_cfg = dict(
-    mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_bgr=False)
+img_norm_cfg = dict(mean=[128, 128], std=[128, 128])
 train_pipeline = [
     dict(type='SampleFrames', clip_len=5, frame_interval=1, num_clips=3),
     dict(type='RawFrameDecode'),
diff --git a/configs/recognition/tsn/tsn_r50_320p_1x1x8_110e_kinetics400_flow.py b/configs/recognition/tsn/tsn_r50_320p_1x1x8_110e_kinetics400_flow.py
--- a/configs/recognition/tsn/tsn_r50_320p_1x1x8_110e_kinetics400_flow.py
+++ b/configs/recognition/tsn/tsn_r50_320p_1x1x8_110e_kinetics400_flow.py
@@ -7,8 +7,7 @@
 ann_file_train = 'data/kinetics400/kinetics400_flow_train_list_320p.txt'
 ann_file_val = 'data/kinetics400/kinetics400_flow_val_list_320p.txt'
 ann_file_test = 'data/kinetics400/kinetics400_flow_val_list_320p.txt'
-img_norm_cfg = dict(
-    mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_bgr=False)
+img_norm_cfg = dict(mean=[128, 128], std=[128, 128])
 train_pipeline = [
     dict(type='SampleFrames', clip_len=5, frame_interval=1, num_clips=8),
     dict(type='RawFrameDecode'),


Test patch:
Repository: blaze/blaze

Issue:
By of merged columns has stopped working.
Previously, the following code would work:

```
from __future__ import absolute_import, division, print_function
import math

from blaze.compute.python import *
from blaze.compute import *
from blaze.data import CSV
from blaze.expr.table import *
from blaze.expr.core import *
from blaze.compatibility import builtins

data = [(1, 2, 'ALICE'),
        (1, 3, 'BOB'),
        (2, 4, 'ALICE'),
        (2, 4, 'ALICE'),
        (2, 4, ''),
        (1, 12, 'BOB')]


s = '{t1:int64, t2:int64, name: string}'
t = TableSymbol('test', s)
tsel = t[ t['name'] != '' ]
tfinal = (tsel['t2']-tsel['t1']).map(lambda x: int(x), schema="{'diff': float64}", iscolumn=True )
lowert = tsel['name'].map(lambda x: x.lower(), schema="{'name': string}", iscolumn=True )
something = merge(tfinal, lowert)
gby = By(something, something['name'], something['diff'].mean())
ans = list(compute(gby, data))
print(ans)
```

As of the latest master, it does not. This code was working as of commit 3e2d394efd85ded07a0e32c2e42f4eced56c3ab9 with output:

```
[('bob', 6.5), ('alice', 1.6666666666666667)]
```

This functionality is important for some visualization/demo work.



Discussion:
I'll take a look at this in a bit.  Until then a couple of usability suggestions

`from blaze import *` imports all of what you need.  Imports have improved a lot in the last month.  

Use `by` instead of `By`

You might want to just define

```
t = Table(data, schema=s)
```

Then you can work interactively.  I find that I prefer this for interactive work.  The way you do it though is of course more explicit and closer to the metal.


Resolving patch:
diff --git a/blaze/compute/python.py b/blaze/compute/python.py
--- a/blaze/compute/python.py
+++ b/blaze/compute/python.py
@@ -242,7 +242,7 @@ def binop2(acc, x):
         d = reduceby(grouper, binop2, seq, initial)
     else:
         groups = groupby(grouper, seq)
-        d = dict((k, compute(t.apply, v)) for k, v in groups.items())
+        d = dict((k, compute(t.apply, {t.child: v})) for k, v in groups.items())
 
     if t.grouper.iscolumn:
         return d.items()


Test patch:
diff --git a/blaze/compute/tests/test_python_compute.py b/blaze/compute/tests/test_python_compute.py
--- a/blaze/compute/tests/test_python_compute.py
+++ b/blaze/compute/tests/test_python_compute.py
@@ -389,3 +389,20 @@ def test_recursive_rowfunc_is_used():
     expected = [('Alice', 2*(101 + 53)),
                 ('Bob', 2*(202))]
     assert set(compute(expr, data)) == set(expected)
+
+
+def test_by_groupby_deep():
+    data = [(1, 2, 'Alice'),
+            (1, 3, 'Bob'),
+            (2, 4, 'Alice'),
+            (2, 4, '')]
+
+    schema = '{x: int, y: int, name: string}'
+    t = TableSymbol('t', schema)
+
+    t2 = t[t['name'] != '']
+    t3 = merge(t2.x, t2.name)
+    expr = by(t3, t3.name, t3.x.mean())
+    result = set(compute(expr, data))
+    assert result == set([('Alice', 1.5), ('Bob', 1.0)])
+
Repository: blaze/blaze

Issue:
Make blaze.test() return True or False
@asmeurer suggests this. Currently we're passing through pytest.main() which is like the error code from command line programs.

<!---
@huboard:{"order":398.859375,"milestone_order":452,"custom_state":""}
-->



Discussion:

Resolving patch:
diff --git a/blaze/__init__.py b/blaze/__init__.py
--- a/blaze/__init__.py
+++ b/blaze/__init__.py
@@ -139,4 +139,4 @@ def test(verbose=False, junitfile=None, exit=False):
     error_code = pytest.main(args=args)
     if exit:
         return sys.exit(error_code)
-    return error_code
+    return error_code == 0


Test patch:
Repository: blaze/blaze

Issue:
Pandas By no longer works on rowwise groupers
In particular something like the following does not work:

```
by(t.map(func), t.col.reduction)
```

cc @cpcloud 



Discussion:
well that's not cool, hotfix time!


Resolving patch:
diff --git a/blaze/compute/pandas.py b/blaze/compute/pandas.py
--- a/blaze/compute/pandas.py
+++ b/blaze/compute/pandas.py
@@ -29,7 +29,8 @@
 from ..dispatch import dispatch
 from ..expr import (Projection, Column, Sort, Head, ColumnWise, Selection,
                     Reduction, Distinct, Join, By, Summary, Label, ReLabel,
-                    Map, Apply, Merge, Union, TableExpr, std, var, Like)
+                    Map, Apply, Merge, Union, TableExpr, std, var, Like,
+                    RowWise)
 from ..expr import UnaryOp, BinOp
 from ..expr import TableSymbol, common_subexpression
 from .core import compute, compute_up, base
@@ -174,7 +175,7 @@ def unpack(seq):
     return seq
 
 
-Grouper = Column, ColumnWise, Series, list
+Grouper = RowWise, Series, list
 
 
 @dispatch(By, list, DataFrame)
@@ -182,7 +183,7 @@ def get_grouper(c, grouper, df):
     return grouper
 
 
-@dispatch(By, (Column, ColumnWise, Series), NDFrame)
+@dispatch(By, (RowWise, Series), NDFrame)
 def get_grouper(c, grouper, df):
     return compute(grouper, {c.child: df})
 


Test patch:
diff --git a/blaze/compute/tests/test_pandas_compute.py b/blaze/compute/tests/test_pandas_compute.py
--- a/blaze/compute/tests/test_pandas_compute.py
+++ b/blaze/compute/tests/test_pandas_compute.py
@@ -533,6 +533,7 @@ def test_nested_transform():
     df['date'] = df.timestamp.map(lambda x: x.date())
     assert str(result) == str(df)
 
+
 def test_like():
     expr = t.like(name='Alice*')
     expected = DataFrame([['Alice', 100, 1],
@@ -541,3 +542,19 @@ def test_like():
 
     result = compute(expr, df).reset_index(drop=True)
     assert (result == expected).all().all()
+
+
+def test_rowwise_by():
+    f = lambda _, id, name: id + len(name)
+    expr = by(t.map(f), t.amount.sum())
+
+    df = pd.DataFrame({'id': [1, 1, 2],
+                       'name': ['alice', 'wendy', 'bob'],
+                       'amount': [100, 200, 300.03]})
+    expected = pd.DataFrame([(5, 300.03), (6, 300)], columns=['index',
+                                                              'amount_sum'])
+
+    result = compute(expr, df)
+    assert expected.index.tolist() == result.index.tolist()
+    assert expected.columns.tolist() == result.columns.tolist()
+    assert expected.values.tolist() == result.values.tolist()
Repository: blaze/blaze

Issue:
SQL can't handle unicode in python 2
A test such as this fails

``` python
t = TableSymbol('t', '{name: string, amount: int, id: int}')

metadata = sa.MetaData()

s = sa.Table('accounts', metadata,
             sa.Column('name', sa.String),
             sa.Column('amount', sa.Integer),
             sa.Column('id', sa.Integer, primary_key=True),
             )

def test_eq_str():
    assert str(compute(t['name'] == u'Alice', s)) == str(s.c.name == u'Alice')
```



Discussion:

Resolving patch:
diff --git a/blaze/compute/core.py b/blaze/compute/core.py
--- a/blaze/compute/core.py
+++ b/blaze/compute/core.py
@@ -10,7 +10,7 @@
 
 __all__ = ['compute', 'compute_up', 'drop', 'create_index']
 
-base = (numbers.Real, str, date, datetime)
+base = (numbers.Real, basestring, date, datetime)
 
 
 @dispatch(object, object)
diff --git a/blaze/compute/sql.py b/blaze/compute/sql.py
--- a/blaze/compute/sql.py
+++ b/blaze/compute/sql.py
@@ -220,7 +220,6 @@ def compute_up(t, lhs, rhs, **kwargs):
         return sqlalchemy.sql.select(columns, from_obj=join)
 
 
-
 names = {mean: 'avg',
          var: 'variance',
          std: 'stdev'}


Test patch:
diff --git a/blaze/compute/tests/test_sql_compute.py b/blaze/compute/tests/test_sql_compute.py
--- a/blaze/compute/tests/test_sql_compute.py
+++ b/blaze/compute/tests/test_sql_compute.py
@@ -1,7 +1,6 @@
 from __future__ import absolute_import, division, print_function
 
 from blaze.compute.sql import compute, computefull, select, lower_column
-from blaze import SQL
 from blaze.expr import *
 import sqlalchemy
 import sqlalchemy as sa
@@ -30,6 +29,7 @@
 def normalize(s):
     return ' '.join(s.strip().split()).lower()
 
+
 def test_table():
     result = str(computefull(t, s))
     expected = """
@@ -40,7 +40,6 @@ def test_table():
     assert normalize(result) == normalize(expected)
 
 
-
 def test_projection():
     print(compute(t[['name', 'amount']], s))
     assert str(compute(t[['name', 'amount']], s)) == \
@@ -51,6 +50,10 @@ def test_eq():
     assert str(compute(t['amount'] == 100, s)) == str(s.c.amount == 100)
 
 
+def test_eq_unicode():
+    assert str(compute(t['name'] == u'Alice', s)) == str(s.c.name == u'Alice')
+
+
 def test_selection():
     assert str(compute(t[t['amount'] == 0], s)) == \
             str(sa.select([s]).where(s.c.amount == 0))
Repository: blaze/blaze

Issue:
into for datetimes
```
In [30]: from blaze import into

In [31]: import datetime

In [32]: into(np.datetime64, datetime.datetime.now())
NotImplementedError: Blaze does not know a rule for the following conversion
datetime64 <- datetime
```

this comes up when needing to get out a value out of a reduction

```
In [51]: from blaze import into, Data

In [52]: c = pd.date_range(start='now', periods=10).to_series().reset_index(drop=True)

In [53]: d = Data(c.to_frame(name='a'))

In [54]: d.a.min()
Out[54]: Timestamp('2014-11-10 20:12:57')

In [55]: type(d.a.min())
Out[55]: blaze.expr.reductions.min
```



Discussion:

Resolving patch:
diff --git a/blaze/api/into.py b/blaze/api/into.py
--- a/blaze/api/into.py
+++ b/blaze/api/into.py
@@ -1023,6 +1023,31 @@ def into(a, b, **kwargs):
     return a(b)
 
 
+@dispatch(np.datetime64, (datetime, np.datetime64))
+def into(_, b, **kwargs):
+    return np.datetime64(b)
+
+
+@dispatch(np.datetime64, pd.Timestamp)
+def into(_, b, **kwargs):
+    return b.asm8
+
+
+@dispatch(pd.Timestamp, (datetime, np.datetime64, pd.Timestamp))
+def into(_, b, **kwargs):
+    return pd.Timestamp(b)
+
+
+@dispatch(datetime, pd.Timestamp)
+def into(_, b, **kwargs):
+    return b.to_pydatetime()
+
+
+@dispatch(datetime, np.datetime64)
+def into(_, b, **kwargs):
+    return b.item()
+
+
 @dispatch(object)
 def into(a, **kwargs):
     """ Curried into function


Test patch:
diff --git a/blaze/api/tests/test_into.py b/blaze/api/tests/test_into.py
--- a/blaze/api/tests/test_into.py
+++ b/blaze/api/tests/test_into.py
@@ -9,6 +9,7 @@
 from datashape import dshape
 from datetime import datetime
 import os
+import itertools
 
 from blaze.compute.chunks import ChunkIterator, chunks
 
@@ -584,3 +585,24 @@ def test_into_df_with_names_from_series():
 
     with pytest.raises(AssertionError):
         into(pd.DataFrame(columns=list('ab')), s)
+
+
+def test_into_datetimes():
+    x = pd.Timestamp('now')
+    y = np.datetime64('now')
+    z = datetime.now()
+
+    # we only want a, b where the types of a and b are not the same
+    p = filter(lambda x: type(x[0]) != type(x[1]),
+               itertools.product([x, y, z], [x, y, z]))
+
+    for a, b in p:
+        r = into(a, b)
+        assert isinstance(r, type(a))
+        r = into(b, a)
+        assert isinstance(r, type(b))
+
+
+def test_into_data_reduction():
+    d = Data(pd.DataFrame({'a': pd.date_range(start='now', periods=10).values}))
+    assert isinstance(into(pd.Timestamp, d.a.min()), pd.Timestamp)
Repository: blaze/blaze

Issue:
Truncate column name is too verbose
Do we have to have a unique name for the result of such operations?

How about having it renamed to the unit, i.e. instead of `when_datetimetruncate` we use `when_day` or `when_week`, etc?



Discussion:
i also wonder if this could be true

``` python
t.when.day.truncate(5) == t.when.truncate(5, 'day')
```

We don't need to have unique names.   Setting the following seems reasonable to me.

``` Python
@property
def _name(self):
    return self._child._name
```

In regards to the following

```
t.when.day.truncate(5) == t.when.truncate(5, 'day')
```

I'm not yet sure how to make that clean.  `.day` might mean something else.  Also, note that the alternative kwarg syntax is fairly natural.

```
t.when.truncate(days=5)
```


Resolving patch:
diff --git a/blaze/expr/datetime.py b/blaze/expr/datetime.py
--- a/blaze/expr/datetime.py
+++ b/blaze/expr/datetime.py
@@ -135,6 +135,10 @@ def _dtype(self):
         else:
             return datashape.datetime_
 
+    @property
+    def _name(self):
+        return self._child._name
+
 
 def truncate(expr, *args, **kwargs):
     """ Truncate datetime expression


Test patch:
diff --git a/blaze/expr/tests/test_datetime.py b/blaze/expr/tests/test_datetime.py
--- a/blaze/expr/tests/test_datetime.py
+++ b/blaze/expr/tests/test_datetime.py
@@ -44,3 +44,8 @@ def test_isdatelike():
     assert not isdatelike('int32')
     assert isdatelike('?date')
     assert not isdatelike('{is_outdated: bool}')
+
+
+def test_truncate_names():
+    t = symbol('t', '5 * {name: string, when: datetime}')
+    assert t.when.truncate(days=2)._name == 'when'
Repository: blaze/blaze

Issue:
Pandas Boolean Arithmetic Display
Boolean arithmetic with a `Data(pandas.DataFrame)` seems to mess up its interactive display, but the actual expression is fully funcitonal.

``` Python
>>> import blaze as bz
>>> import pandas as pd
>>> data = bz.Data(pd.read_csv("iris.csv"))
>>> data
    SepalLength  SepalWidth  PetalLength  PetalWidth         Name
0           5.1         3.5          1.4         0.2  Iris-setosa
1           4.9         3.0          1.4         0.2  Iris-setosa
2           4.7         3.2          1.3         0.2  Iris-setosa
3           4.6         3.1          1.5         0.2  Iris-setosa
4           5.0         3.6          1.4         0.2  Iris-setosa
5           5.4         3.9          1.7         0.4  Iris-setosa
6           4.6         3.4          1.4         0.3  Iris-setosa
7           5.0         3.4          1.5         0.2  Iris-setosa
8           4.4         2.9          1.4         0.2  Iris-setosa
9           4.9         3.1          1.5         0.1  Iris-setosa
...
>>> (data.SepalLength > 5.0) & (data.SepalLength < 5.5)
Empty DataFrame
Columns: [None]
Index: []

>>> bz.compute( (data.SepalLength > 5.0) & (data.SepalLength < 5.5) )
0      True
1     False
2     False
3     False
4     False
...
145    False
146    False
147    False
148    False
149    False
Name: SepalLength, Length: 150, dtype: bool

>>> data[(data.SepalLength > 5.0) & (data.SepalLength < 5.5)]
    SepalLength  SepalWidth  PetalLength  PetalWidth         Name
0           5.1         3.5          1.4         0.2  Iris-setosa
5           5.4         3.9          1.7         0.4  Iris-setosa
10          5.4         3.7          1.5         0.2  Iris-setosa
16          5.4         3.9          1.3         0.4  Iris-setosa
17          5.1         3.5          1.4         0.3  Iris-setosa
19          5.1         3.8          1.5         0.3  Iris-setosa
20          5.4         3.4          1.7         0.2  Iris-setosa
21          5.1         3.7          1.5         0.4  Iris-setosa
23          5.1         3.3          1.7         0.5  Iris-setosa
27          5.2         3.5          1.5         0.2  Iris-setosa
...
```



Discussion:

Resolving patch:
diff --git a/blaze/expr/arithmetic.py b/blaze/expr/arithmetic.py
--- a/blaze/expr/arithmetic.py
+++ b/blaze/expr/arithmetic.py
@@ -46,6 +46,8 @@ def _name(self):
             return l
         if r and not l:
             return r
+        if l == r:
+            return l
 
     @property
     def _inputs(self):


Test patch:
diff --git a/blaze/expr/tests/test_arithmetic.py b/blaze/expr/tests/test_arithmetic.py
--- a/blaze/expr/tests/test_arithmetic.py
+++ b/blaze/expr/tests/test_arithmetic.py
@@ -32,6 +32,8 @@ def test_names():
     assert Add(y, x)._name != x._name
     assert Add(y, x)._name != y._name
 
+    assert Add(x, x)._name == x._name
+
 def test_inputs():
     assert (x + y)._inputs == (x, y)
     assert (x + 1)._inputs == (x,)
Repository: blaze/blaze

Issue:
python: negative slicing with tail
``` Python
In [1]: from blaze import *

In [2]: s = Symbol('s', 'var * int')

In [3]: compute(s[-1], [1, 2, 3])
Out[3]: 3

In [4]: compute(s[-1], iter([1, 2, 3])) # works on lazy sequences too
Out[4]: 3
```



Discussion:

Resolving patch:
diff --git a/blaze/compute/python.py b/blaze/compute/python.py
--- a/blaze/compute/python.py
+++ b/blaze/compute/python.py
@@ -19,7 +19,7 @@
 import re
 from collections import Iterator
 from functools import partial
-from toolz import map, filter, compose, juxt, identity
+from toolz import map, filter, compose, juxt, identity, tail
 from cytoolz import groupby, reduceby, unique, take, concat, first, nth, pluck
 import datetime
 import cytoolz
@@ -646,9 +646,20 @@ def compute_up(expr, seq, **kwargs):
     if isinstance(index, tuple) and len(index) == 1:
         index = index[0]
     if isinstance(index, _inttypes):
-        return nth(index, seq)
+        try:
+            return seq[index]
+        except:
+            if index >= 0:
+                return nth(index, seq)
+            else:
+                return tail(-index, seq)[0]
     if isinstance(index, slice):
-        return itertools.islice(seq, index.start, index.stop, index.step)
+        if (index.start and index.start < 0 and
+            index.stop is None and
+            index.step in (1, None)):
+            return tail(-index.start, seq)
+        else:
+            return itertools.islice(seq, index.start, index.stop, index.step)
     raise NotImplementedError("Only 1d slices supported")
 
 


Test patch:
diff --git a/blaze/compute/tests/test_python_compute.py b/blaze/compute/tests/test_python_compute.py
--- a/blaze/compute/tests/test_python_compute.py
+++ b/blaze/compute/tests/test_python_compute.py
@@ -693,6 +693,21 @@ def test_slice():
     assert list(compute(t.name[:2], data)) == [data[0][0], data[1][0]]
 
 
+def test_negative_slicing():
+    assert list(compute(t[-1:], data)) == data[-1:]
+    assert list(compute(t[-1:], iter(data))) == data[-1:]
+    assert list(compute(t[-1], data)) == data[-1]
+    assert list(compute(t[-1], iter(data))) == data[-1]
+    assert list(compute(t[-2], data)) == data[-2]
+    assert list(compute(t[-2], iter(data))) == data[-2]
+
+
+@pytest.mark.xfail(raises=ValueError,
+                   reason="No support for stop and step having negative values")
+def test_negative_slicing_raises_on_stop_and_step_not_None():
+    assert list(compute(t[-2:-5:-1], data)) == data[-2:-5:-1]
+
+
 def test_multi_dataset_broadcast():
     x = symbol('x', '3 * int')
     y = symbol('y', '3 * int')