Repository: dask/dask

Issue:
Use da.eye with chunks="auto" fails
Currently if a user tries to create an array with `da.eye(..., chunks="auto")`, it fails. An MRE is included below.

<details>
<summary>Example:</summary>

```python
In [1]: import dask.array as da                                                 
da.ey	
In [2]: da.eye(100, chunks=10)                                                  
Out[2]: dask.array<eye, shape=(100, 100), dtype=float64, chunksize=(10, 10)>

In [3]: da.eye(100, chunks="auto")                                              
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-80d20afa2a92> in <module>
----> 1 da.eye(100, chunks="auto")

~/Developer/dask/dask/array/creation.py in eye(N, chunks, M, k, dtype)
    437     """
    438     if not isinstance(chunks, Integral):
--> 439         raise ValueError('chunks must be an int')
    440 
    441     token = tokenize(N, chunk, M, k, dtype)

ValueError: chunks must be an int
```

</details>

<br>

<details>
<summary>Environment:</summary>

```yaml
name: daskdev
channels:
  - conda-forge
  - defaults
dependencies:
  - appnope=0.1.0=py37_1000
  - asn1crypto=0.24.0=py37_1003
  - attrs=19.1.0=py_0
  - backcall=0.1.0=py_0
  - blas=1.1=openblas
  - bleach=3.1.0=py_0
  - bokeh=1.0.4=py37_1000
  - bzip2=1.0.6=h1de35cc_1002
  - ca-certificates=2019.3.9=hecc5488_0
  - certifi=2019.3.9=py37_0
  - cffi=1.12.2=py37h2d6ddff_1
  - chardet=3.0.4=py37_1003
  - click=7.0=py_0
  - cloudpickle=0.8.0=py_0
  - cryptography=2.6.1=py37hc2b1221_0
  - cycler=0.10.0=py_1
  - cytoolz=0.9.0.1=py37h470a237_1
  - dask-glm=0.1.0=0
  - dask-ml=0.12.0=py_0
  - decorator=4.3.2=py_0
  - defusedxml=0.5.0=py_1
  - distributed=1.26.0=py37_1
  - entrypoints=0.3=py37_1000
  - freetype=2.9.1=h597ad8a_1005
  - heapdict=1.0.0=py37_1000
  - idna=2.8=py37_1000
  - imageio=2.5.0=py37_0
  - ipykernel=5.1.0=py37h24bf2e0_1002
  - ipython=7.3.0=py37h24bf2e0_0
  - ipython_genutils=0.2.0=py_1
  - jedi=0.13.3=py37_0
  - jinja2=2.10=py_1
  - jpeg=9c=h1de35cc_1001
  - jsonschema=3.0.1=py37_0
  - jupyter_client=5.2.4=py_3
  - jupyter_core=4.4.0=py_0
  - kiwisolver=1.0.1=py37h04f5b5a_1002
  - libcxx=7.0.0=h2d50403_1
  - libffi=3.2.1=h0a44026_1005
  - libgfortran=3.0.1=0
  - libpng=1.6.36=ha441bb4_1000
  - libsodium=1.0.16=h1de35cc_1001
  - libtiff=4.0.10=h79f4b77_1001
  - llvm-meta=7.0.0=0
  - llvmlite=0.26.0=py37h8c7ce04_0
  - locket=0.2.0=py_2
  - markupsafe=1.1.1=py37h1de35cc_0
  - matplotlib-base=3.0.3=py37hf043ca5_0
  - mistune=0.8.4=py37h1de35cc_1000
  - msgpack-python=0.6.1=py37h04f5b5a_0
  - multipledispatch=0.6.0=py_0
  - nbconvert=5.4.1=py_2
  - nbformat=4.4.0=py_1
  - ncurses=6.1=h0a44026_1002
  - networkx=2.2=py_1
  - notebook=5.7.6=py37_0
  - numba=0.41.0=py37h1702cab_1000
  - numpy=1.16.2=py37_blas_openblash486cb9f_0
  - olefile=0.46=py_0
  - openblas=0.3.3=hdc02c5d_1001
  - openssl=1.1.1b=h1de35cc_1
  - packaging=19.0=py_0
  - pandas=0.24.2=py37h0a44026_0
  - pandoc=2.6=1
  - pandocfilters=1.4.2=py_1
  - parso=0.3.4=py_0
  - partd=0.3.9=py_0
  - pexpect=4.6.0=py37_1000
  - pickleshare=0.7.5=py37_1000
  - pillow=5.4.1=py37hbddbef0_1000
  - pip=19.0.3=py37_0
  - prometheus_client=0.6.0=py_0
  - prompt_toolkit=2.0.9=py_0
  - psutil=5.6.1=py37h1de35cc_0
  - ptyprocess=0.6.0=py37_1000
  - pycparser=2.19=py37_1
  - pygments=2.3.1=py_0
  - pyopenssl=19.0.0=py37_0
  - pyparsing=2.3.1=py_0
  - pyrsistent=0.14.11=py37h1de35cc_0
  - pysocks=1.6.8=py37_1002
  - python=3.7.1=hbdd33cc_1003
  - python-dateutil=2.8.0=py_0
  - pytz=2018.9=py_0
  - pywavelets=1.0.2=py37h917ab60_0
  - pyyaml=5.1=py37h1de35cc_0
  - pyzmq=18.0.1=py37h4cc6ddd_0
  - readline=7.0=hcfe32e1_1001
  - requests=2.21.0=py37_1000
  - scikit-image=0.14.2=py37h0a44026_1
  - scikit-learn=0.20.3=py37_blas_openblashc6dc708_0
  - scipy=1.2.1=py37_blas_openblash486cb9f_0
  - send2trash=1.5.0=py_0
  - setuptools=40.8.0=py37_0
  - six=1.12.0=py37_1000
  - sortedcontainers=2.1.0=py_0
  - sparse=0.6.0=py_0
  - sqlite=3.26.0=h1765d9f_1001
  - tblib=1.3.2=py_1
  - terminado=0.8.1=py37_1001
  - testpath=0.4.2=py37_1000
  - tk=8.6.9=ha441bb4_1000
  - toolz=0.9.0=py_1
  - tornado=6.0.1=py37h1de35cc_0
  - traitlets=4.3.2=py37_1000
  - urllib3=1.24.1=py37_1000
  - wcwidth=0.1.7=py_1
  - webencodings=0.5.1=py_1
  - wheel=0.33.1=py37_0
  - xz=5.2.4=h1de35cc_1001
  - yaml=0.1.7=h1de35cc_1001
  - zeromq=4.2.5=h0a44026_1006
  - zict=0.1.4=py_0
  - zlib=1.2.11=h1de35cc_1004
```

</details>

Discussion:
andersy005: @jrbourbeau, thank you for reviewing this! Let me know if there are any additional changes needed. 
jrbourbeau: Thanks for addressing my comments so quickly! I'm about to go offline for a little bit, but will do a final review in a few hours. 

> Do you know why travis isn't re-running checks on this PR after adding more commits to it?

My guess is it's related to https://www.githubstatus.com/incidents/nf4gcjtcsqdb
TomAugspurger: Thanks @andersy005! Does this fully close https://github.com/dask/dask/issues/4635? It looks like @lightsighter may have wanted something like

```
da.eye(12, chunks=(4, 3))
```

to work.

If so, we can still merge this PR because it's valuable as is, but we'll want to remove the "Fixes" in the original post so that the issue remains open.
andersy005: @TomAugspurger, 

Regarding 

```
da.eye(12, chunks=(4, 3))
```
I will take a stab at it, and see if I can get it to work as part of this PR. 


jakirkham: I think @lightsighter is more interested in `da.eye(12, chunks="auto")` than anisotropic chunking. Though I suppose if `"auto"` resulted in anisotropic chunking, then he would want that indirectly.
TomAugspurger: To be clear, I have no objections to merging this as is (well, once the docstring is updated).

@lighsighter can you confirm that something like `chunks='auto'` suffices for you? Or were you also hoping for something like `da.eye(12, chunks=(4, 3))`.
jakirkham: @lightsighter, if you are around, would you have a chance to answer Tom's question ([above]( https://github.com/dask/dask/pull/4834#issuecomment-495293733 )) and see if this PR solves the issue you encountered?
lightsighter: I really wanted both so I could compare performance. I would have a preference though for 'chunks=(4,3)' over 'chunks="auto"' though because I really ultimately want the ability to pick my chunk sizes like I can for other Dask operations.

Patch:
diff --git a/dask/array/creation.py b/dask/array/creation.py
index 76dafa092..4b5d85f0b 100644
--- a/dask/array/creation.py
+++ b/dask/array/creation.py
@@ -411,7 +411,7 @@ def indices(dimensions, dtype=int, chunks='auto'):
     return grid
 
 
-def eye(N, chunks, M=None, k=0, dtype=float):
+def eye(N, chunks='auto', M=None, k=0, dtype=float):
     """
     Return a 2-D Array with ones on the diagonal and zeros elsewhere.
 
@@ -419,8 +419,13 @@ def eye(N, chunks, M=None, k=0, dtype=float):
     ----------
     N : int
       Number of rows in the output.
-    chunks: int
-        chunk size of resulting blocks
+    chunks : int, str
+        How to chunk the array. Must be one of the following forms:
+        -   A blocksize like 1000.
+        -   A size in bytes, like "100 MiB" which will choose a uniform
+            block-like shape
+        -   The word "auto" which acts like the above, but uses a configuration
+            value ``array.chunk-size`` for the chunk size
     M : int, optional
       Number of columns in the output. If None, defaults to `N`.
     k : int, optional
@@ -436,16 +441,18 @@ def eye(N, chunks, M=None, k=0, dtype=float):
       An array where all elements are equal to zero, except for the `k`-th
       diagonal, whose values are equal to one.
     """
-    if not isinstance(chunks, Integral):
-        raise ValueError('chunks must be an int')
-
-    token = tokenize(N, chunk, M, k, dtype)
-    name_eye = 'eye-' + token
-
     eye = {}
     if M is None:
         M = N
 
+    if not isinstance(chunks, (int, str)):
+        raise ValueError('chunks must be an int or string')
+    elif isinstance(chunks, str):
+        chunks = normalize_chunks(chunks, shape=(N, M), dtype=dtype)
+        chunks = chunks[0][0]
+    token = tokenize(N, chunks, M, k, dtype)
+    name_eye = 'eye-' + token
+
     vchunks = [chunks] * (N // chunks)
     if N % chunks != 0:
         vchunks.append(N % chunks)
diff --git a/dask/array/linalg.py b/dask/array/linalg.py
index 45418304b..070ade979 100644
--- a/dask/array/linalg.py
+++ b/dask/array/linalg.py
@@ -1104,7 +1104,8 @@ def lstsq(a, b):
                            (np.dot, (rt.name, 0, 0), (r.name, 0, 0)))))}
     graph = HighLevelGraph.from_collections(sname, sdsk, dependencies=[rt])
     _, _, _, ss = np.linalg.lstsq(np.array([[1, 0], [1, 2]], dtype=a.dtype),
-                                  np.array([0, 1], dtype=b.dtype))
+                                  np.array([0, 1], dtype=b.dtype),
+                                  rcond=-1)
     s = Array(graph, sname, shape=(r.shape[0], ),
               chunks=r.shape[0], dtype=ss.dtype)
 
diff --git a/dask/array/numpy_compat.py b/dask/array/numpy_compat.py
index 590224c53..4e7defdf6 100644
--- a/dask/array/numpy_compat.py
+++ b/dask/array/numpy_compat.py
@@ -5,6 +5,9 @@ from distutils.version import LooseVersion
 import numpy as np
 import warnings
 
+_numpy_116 = LooseVersion(np.__version__) >= "1.16.0"
+
+
 # Taken from scikit-learn:
 # https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/fixes.py#L84
 try:
@@ -271,3 +274,9 @@ class _Recurser(object):
             # yield from ...
             for v in self.walk(xi, index + (i,)):
                 yield v
+
+
+if _numpy_116:
+    _unravel_index_keyword = "shape"
+else:
+    _unravel_index_keyword = "dims"
diff --git a/dask/array/routines.py b/dask/array/routines.py
index 6ecbdb96a..c04230936 100644
--- a/dask/array/routines.py
+++ b/dask/array/routines.py
@@ -25,6 +25,7 @@ from .core import (Array, map_blocks, elemwise, from_array, asarray,
                    is_scalar_for_elemwise, broadcast_to, tensordot_lookup)
 
 from .einsumfuncs import einsum  # noqa
+from .numpy_compat import _unravel_index_keyword
 
 
 @derived_from(np)
@@ -1175,13 +1176,14 @@ def _unravel_index_kernel(indices, func_kwargs):
 
 @derived_from(np)
 def unravel_index(indices, dims, order='C'):
+    # TODO: deprecate dims as well?
     if dims and indices.size:
         unraveled_indices = tuple(indices.map_blocks(
             _unravel_index_kernel,
             dtype=np.intp,
             chunks=(((len(dims),),) + indices.chunks),
             new_axis=0,
-            func_kwargs={"dims": dims, "order": order}
+            func_kwargs={_unravel_index_keyword: dims, "order": order}
         ))
     else:
         unraveled_indices = tuple(
diff --git a/dask/bag/core.py b/dask/bag/core.py
index 89ac6ee21..474ed0194 100644
--- a/dask/bag/core.py
+++ b/dask/bag/core.py
@@ -1113,6 +1113,37 @@ class Bag(DaskMethodsMixin):
 
         >>> b.foldby('name', binop, 0, combine, 0)  # doctest: +SKIP
 
+        Examples
+        --------
+
+        We can compute the maximum of some ``(key, value)`` pairs, grouped
+        by the ``key``. (You might be better off converting the ``Bag`` to
+        a ``dask.dataframe`` and using its groupby).
+
+        >>> import random
+        >>> import dask.bag as db
+
+        >>> tokens = list('abcdefg')
+        >>> values = range(10000)
+        >>> a = [(random.choice(tokens), random.choice(values))
+        ...       for _ in range(100)]
+        >>> a[:2]  # doctest: +SKIP
+        [('g', 676), ('a', 871)]
+
+        >>> a = db.from_sequence(a)
+
+        >>> def binop(t, x):
+        ...     return max((t, x), key=lambda x: x[1])
+
+        >>> a.foldby(lambda x: x[0], binop).compute()  # doctest: +SKIP
+        [('g', ('g', 984)),
+         ('a', ('a', 871)),
+         ('b', ('b', 999)),
+         ('c', ('c', 765)),
+         ('f', ('f', 955)),
+         ('e', ('e', 991)),
+         ('d', ('d', 854))]
+
         See Also
         --------
 
diff --git a/dask/blockwise.py b/dask/blockwise.py
index 3e78b1e6d..51c0195c9 100644
--- a/dask/blockwise.py
+++ b/dask/blockwise.py
@@ -1,4 +1,5 @@
 import itertools
+import warnings
 
 import numpy as np
 try:
@@ -436,10 +437,26 @@ def optimize_blockwise(graph, keys=()):
     --------
     rewrite_blockwise
     """
-    out = _optimize_blockwise(graph, keys=keys)
-    while out.dependencies != graph.dependencies:
-        graph = out
+    with warnings.catch_warnings():
+        # In some cases, rewrite_blockwise (called internally) will do a bad
+        # thing like `string in array[int].
+        # See dask/array/tests/test_atop.py::test_blockwise_numpy_arg for
+        # an example. NumPy currently raises a warning that 'a' == array([1, 2])
+        # will change from returning `False` to `array([False, False])`.
+        #
+        # Users shouldn't see those warnings, so we filter them.
+        # We set the filter here, rather than lower down, to avoid having to
+        # create and remove the filter many times inside a tight loop.
+
+        # https://github.com/dask/dask/pull/4805#discussion_r286545277 explains
+        # why silencing this warning shouldn't cause issues.
+        warnings.filterwarnings("ignore",
+                                "elementwise comparison failed",
+                                Warning)  # FutureWarning or DeprecationWarning
         out = _optimize_blockwise(graph, keys=keys)
+        while out.dependencies != graph.dependencies:
+            graph = out
+            out = _optimize_blockwise(graph, keys=keys)
     return out
 
 
diff --git a/dask/optimization.py b/dask/optimization.py
index 82075d779..a42bdfe80 100644
--- a/dask/optimization.py
+++ b/dask/optimization.py
@@ -470,7 +470,7 @@ def fuse(dsk, keys=None, dependencies=None, ave_width=None, max_width=None,
     tune the behavior, which are described below.  ``ave_width`` is the
     natural parameter with which to compare parallelism to granularity, so
     it should always be specified.  Reasonable values for other parameters
-    with be determined using ``ave_width`` if necessary.
+    will be determined using ``ave_width`` if necessary.
 
     Parameters
     ----------
diff --git a/docs/source/array-overlap.rst b/docs/source/array-overlap.rst
index f1fcb98bc..809ced3d0 100644
--- a/docs/source/array-overlap.rst
+++ b/docs/source/array-overlap.rst
@@ -142,7 +142,7 @@ you can give your function a keyword argument ``block_id``:
        ...
 
 This extra keyword argument will be given a tuple that provides the block
-location like ``(0, 0)`` for the upper right block or ``(0, 1)`` for the block
+location like ``(0, 0)`` for the upper-left block or ``(0, 1)`` for the block
 just to the right of that block.
 
 
diff --git a/docs/source/support.rst b/docs/source/support.rst
index cae41c335..f09bb2022 100644
--- a/docs/source/support.rst
+++ b/docs/source/support.rst
@@ -63,7 +63,7 @@ likelihood of quickly getting a good answer.
 
 Paid support
 ------------
+In addition to the previous options, paid support is available from
 
-Dask is an open source project that originated at `Anaconda Inc
-<https://www.anaconda.com/>`_.  In addition to the previous options, Anaconda
-offers paid training and support:  `<https://www.anaconda.com/support>`_.
+-   Anaconda: `<https://www.anaconda.com/support>`_
+-   Quansight: `<https://www.quansight.com/open-source-support>`_


Test patch:
diff --git a/dask/array/tests/test_array_core.py b/dask/array/tests/test_array_core.py
index 2da84ff96..c0b3659e9 100644
--- a/dask/array/tests/test_array_core.py
+++ b/dask/array/tests/test_array_core.py
@@ -2037,10 +2037,10 @@ def test_slicing_with_non_ndarrays():
     assert_eq((x + 1).sum(), (np.arange(10, dtype=x.dtype) + 1).sum())
 
 
+@pytest.mark.filterwarnings("ignore:the matrix subclass")
 def test_getter():
-    with warnings.catch_warnings(record=True):
-        assert type(getter(np.matrix([[1]]), 0)) is np.ndarray
-        assert type(getter(np.matrix([[1]]), 0, asarray=False)) is np.matrix
+    assert type(getter(np.matrix([[1]]), 0)) is np.ndarray
+    assert type(getter(np.matrix([[1]]), 0, asarray=False)) is np.matrix
     assert_eq(getter([1, 2, 3, 4, 5], slice(1, 4)), np.array([2, 3, 4]))
 
     assert_eq(getter(np.arange(5), (None, slice(None, None))),
@@ -2164,6 +2164,7 @@ def test_from_array_scalar(type_):
     (True, np.ndarray),
     (False, np.matrix),
 ])
+@pytest.mark.filterwarnings("ignore:the matrix subclass")
 def test_from_array_no_asarray(asarray, cls):
 
     def assert_chunks_are_of_type(x):
@@ -2171,12 +2172,11 @@ def test_from_array_no_asarray(asarray, cls):
         for c in concat(chunks):
             assert type(c) is cls
 
-    with warnings.catch_warnings(record=True):
-        x = np.matrix(np.arange(100).reshape((10, 10)))
-        dx = da.from_array(x, chunks=(5, 5), asarray=asarray)
-        assert_chunks_are_of_type(dx)
-        assert_chunks_are_of_type(dx[0:5])
-        assert_chunks_are_of_type(dx[0:5][:, 0])
+    x = np.matrix(np.arange(100).reshape((10, 10)))
+    dx = da.from_array(x, chunks=(5, 5), asarray=asarray)
+    assert_chunks_are_of_type(dx)
+    assert_chunks_are_of_type(dx[0:5])
+    assert_chunks_are_of_type(dx[0:5][:, 0])
 
 
 def test_from_array_getitem():
@@ -2245,14 +2245,14 @@ def test_asarray_h5py():
             assert not any(isinstance(v, np.ndarray) for v in x.dask.values())
 
 
+@pytest.mark.filterwarnings("ignore:the matrix subclass")
 def test_asanyarray():
-    with warnings.catch_warnings(record=True):
-        x = np.matrix([1, 2, 3])
-        dx = da.asanyarray(x)
-        assert dx.numblocks == (1, 1)
-        chunks = compute_as_if_collection(Array, dx.dask, dx.__dask_keys__())
-        assert isinstance(chunks[0][0], np.matrix)
-        assert da.asanyarray(dx) is dx
+    x = np.matrix([1, 2, 3])
+    dx = da.asanyarray(x)
+    assert dx.numblocks == (1, 1)
+    chunks = compute_as_if_collection(Array, dx.dask, dx.__dask_keys__())
+    assert isinstance(chunks[0][0], np.matrix)
+    assert da.asanyarray(dx) is dx
 
 
 def test_asanyarray_dataframe():
@@ -3095,12 +3095,9 @@ def test_warn_bad_rechunking():
     x = da.ones((20, 20), chunks=(20, 1))
     y = da.ones((20, 20), chunks=(1, 20))
 
-    with warnings.catch_warnings(record=True) as record:
+    with pytest.warns(da.core.PerformanceWarning, match='factor of 20'):
         x + y
 
-    assert record
-    assert '20' in record[0].message.args[0]
-
 
 def test_concatenate_stack_dont_warn():
     with warnings.catch_warnings(record=True) as record:
diff --git a/dask/array/tests/test_atop.py b/dask/array/tests/test_atop.py
index f92fc20bf..2245ff727 100644
--- a/dask/array/tests/test_atop.py
+++ b/dask/array/tests/test_atop.py
@@ -1,4 +1,5 @@
 import collections
+import warnings
 from operator import add
 
 import pytest
@@ -454,7 +455,9 @@ def test_validate_top_inputs():
 
 
 def test_gh_4176():
-    from dask.sharedict import ShareDict
+    with warnings.catch_warnings():
+        warnings.simplefilter('ignore')
+        from dask.sharedict import ShareDict
 
     def foo(A):
         return A[None, ...]
diff --git a/dask/array/tests/test_creation.py b/dask/array/tests/test_creation.py
index a9b091a6e..d84504255 100644
--- a/dask/array/tests/test_creation.py
+++ b/dask/array/tests/test_creation.py
@@ -197,9 +197,9 @@ def test_indices_wrong_chunks():
 
 
 def test_indices_dimensions_chunks():
-    chunks = ((1,4,2,3), (5,5))
+    chunks = ((1, 4, 2, 3), (5, 5))
     darr = da.indices((10, 10), chunks=chunks)
-    assert darr.chunks == ((1,1),) + chunks
+    assert darr.chunks == ((1, 1),) + chunks
 
 
 def test_empty_indicies():
@@ -334,6 +334,7 @@ def test_tril_triu_non_square_arrays():
 
 def test_eye():
     assert_eq(da.eye(9, chunks=3), np.eye(9))
+    assert_eq(da.eye(9), np.eye(9))
     assert_eq(da.eye(10, chunks=3), np.eye(10))
     assert_eq(da.eye(9, chunks=3, M=11), np.eye(9, M=11))
     assert_eq(da.eye(11, chunks=3, M=9), np.eye(11, M=9))
@@ -349,6 +350,10 @@ def test_eye():
     assert_eq(da.eye(9, chunks=3, dtype=int), np.eye(9, dtype=int))
     assert_eq(da.eye(10, chunks=3, dtype=int), np.eye(10, dtype=int))
 
+    with dask.config.set({'array.chunk-size': '50 MiB'}):
+        x = da.eye(10000, 'auto')
+        assert 4 < x.npartitions < 32
+
 
 def test_diag():
     v = np.arange(11)
diff --git a/dask/array/tests/test_linalg.py b/dask/array/tests/test_linalg.py
index 81049b70b..6fbee1669 100644
--- a/dask/array/tests/test_linalg.py
+++ b/dask/array/tests/test_linalg.py
@@ -611,7 +611,7 @@ def test_lstsq(nrow, ncol, chunk):
     dA = da.from_array(A, (chunk, ncol))
     db = da.from_array(b, chunk)
 
-    x, r, rank, s = np.linalg.lstsq(A, b)
+    x, r, rank, s = np.linalg.lstsq(A, b, rcond=-1)
     dx, dr, drank, ds = da.linalg.lstsq(dA, db)
 
     assert_eq(dx, x)
diff --git a/dask/array/tests/test_ufunc.py b/dask/array/tests/test_ufunc.py
index 5e859b60d..7e8c7b5de 100644
--- a/dask/array/tests/test_ufunc.py
+++ b/dask/array/tests/test_ufunc.py
@@ -252,7 +252,8 @@ def test_angle():
 
 
 def test_issignedinf():
-    arr = np.random.randint(-1, 2, size=(20, 20)).astype(float) / 0
+    with np.errstate(invalid='ignore', divide='ignore'):
+        arr = np.random.randint(-1, 2, size=(20, 20)).astype(float) / 0
     darr = da.from_array(arr, 3)
 
     assert_eq(np.isneginf(arr), da.isneginf(darr))