Repository: dask/dask

Issue:
test_deterministic_reduction_names fails with Bottleneck 1.2.1
I just updated my system from python[23]-Bottleneck 1.2.0 to 1.2.1, and it appears to have caused some trouble with the tests. This only affects Python 2:

```pytb
dask/dataframe/tests/test_arithmetics_reduction.py FF

= =
_ test_deterministic_reduction_names[False] _

split_every = False

    @pytest.mark.parametrize('split_every', [False, 2])
    def test_deterministic_reduction_names(split_every):
        df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8]})
        ddf = dd.from_pandas(df, npartitions=2)
    
        for x in [ddf, ddf.x]:
>           assert (x.sum(split_every=split_every)._name ==
                    x.sum(split_every=split_every)._name)
E           assert 'series-sum-a...81f9d2d482fc3' == 'series-sum-ag...357238beceb29'
E             - series-sum-agg-9c97b6b17a6f3d6d47781f9d2d482fc3
E             + series-sum-agg-3bb4d33cce9c1d8987a357238beceb29

dask/dataframe/tests/test_arithmetics_reduction.py:715: AssertionError
_ test_deterministic_reduction_names[2] _

split_every = 2

    @pytest.mark.parametrize('split_every', [False, 2])
    def test_deterministic_reduction_names(split_every):
        df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [5, 6, 7, 8]})
        ddf = dd.from_pandas(df, npartitions=2)
    
        for x in [ddf, ddf.x]:
>           assert (x.sum(split_every=split_every)._name ==
                    x.sum(split_every=split_every)._name)
E           assert 'series-sum-a...71c3232eb4960' == 'series-sum-ag...de934cf323ffb'
E             - series-sum-agg-06ddb5e85126b94014071c3232eb4960
E             + series-sum-agg-7b5a3dd04b36f3f3130de934cf323ffb

dask/dataframe/tests/test_arithmetics_reduction.py:715: AssertionError
= 17 tests deselected by '-ktest_deterministic_reduction_names' =
= 2 failed, 17 deselected in 0.55 seconds =
```


Discussion:
I rewrote the test to parametrize the `for` loop, and the problem appears only for `ddf.x`, not for plain `ddf`.
I'm not sure how these reduction names are determined, but could [this change in Bottleneck 1.2.1](https://github.com/kwgoodman/bottleneck/issues/168#issuecomment-299590090) be related?
This does not fail for `prod`, `min`, `max`,  `count`, or `nunique`, but fails for the others in the test.
I think my suspicion is correct, as [`int`s are registered with an `identity` transform](https://github.com/dask/dask/blob/master/dask/base.py#L308), but `long`s aren't. This makes `long`s walk the MRO (to `object`), which just returns a new UUID every time.

Resolving patch:
diff --git a/dask/base.py b/dask/base.py
--- a/dask/base.py
+++ b/dask/base.py
@@ -13,7 +13,7 @@
 from toolz.functoolz import Compose
 
 from . import sharedict
-from .compatibility import bind_method, unicode, PY3
+from .compatibility import bind_method, long, unicode, PY3
 from .context import _globals
 from .core import flatten
 from .hashing import hash_buffer_hex
@@ -305,8 +305,8 @@ def _normalize_function(func):
 
 
 normalize_token = Dispatch()
-normalize_token.register((int, float, str, unicode, bytes, type(None), type,
-                          slice, complex),
+normalize_token.register((int, long, float, str, unicode, bytes, type(None),
+                          type, slice, complex),
                          identity)
 
 


Test patch:
diff --git a/dask/tests/test_base.py b/dask/tests/test_base.py
--- a/dask/tests/test_base.py
+++ b/dask/tests/test_base.py
@@ -13,7 +13,7 @@
 from dask.delayed import Delayed
 from dask.utils import tmpdir, tmpfile, ignoring
 from dask.utils_test import inc, dec
-from dask.compatibility import unicode
+from dask.compatibility import long, unicode
 
 
 def import_or_none(path):
@@ -167,7 +167,7 @@ def test_tokenize_numpy_ufunc_consistent():
 
 
 def test_normalize_base():
-    for i in [1, 1.1, '1', slice(1, 2, 3)]:
+    for i in [1, long(1), 1.1, '1', slice(1, 2, 3)]:
         assert normalize_token(i) is i