Skip to content

Test failures with NumPy 1.17.0rc1 #3985

Closed

Description

@jni

Description

Some of our tests are failing with NumPy 1.17.0rc1

https://travis-ci.org/scikit-image/scikit-image/jobs/552547744#L2635

They appear to be related to __array_function__.

Activity

  1. hmaarrfk commented on Jul 1, 2019

    @hmaarrfk
    Member
    _____________________________ test_dask_histogram ______________________________
        def test_dask_histogram():
            pytest.importorskip('dask', reason="dask python library is not installed")
            import dask.array as da
            dask_array = da.from_array(np.array([[0, 1], [1, 2]]), chunks=(1, 2))
    >       output_hist, output_bins = exposure.histogram(dask_array)
    ../../venv/lib/python3.6/site-packages/skimage/exposure/tests/test_exposure.py:566: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    ../../venv/lib/python3.6/site-packages/skimage/exposure/exposure.py:131: in histogram
        hist, bin_centers = _bincount_histogram(image, source_range)
    ../../venv/lib/python3.6/site-packages/skimage/exposure/exposure.py:64: in _bincount_histogram
        image_min = int(np.min(image).astype(np.int64))
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    args = (dask.array<reshape, shape=(4,), dtype=int64, chunksize=(2,)>,)
    kwargs = {}
    relevant_args = (dask.array<reshape, shape=(4,), dtype=int64, chunksize=(2,)>, None)
    >   ???
    E   TypeError: no implementation found for 'numpy.amin' on types that implement __array_function__: [<class 'dask.array.core.Array'>]
    <__array_function__ internals>:6: TypeError
    

    this seems like a numpy + dask issue. Probably should report it upstream.

  2. jni commented on Jul 1, 2019

    @jni
    MemberAuthor

    You're right, it's a failure of dask.array with __array_function__ and np.min. That should definitely work! Using image.min() instead works fine. Reporting now.

  3. shoyer commented on Jul 1, 2019

    @shoyer

    Is this code intended to work by coercing a dask array into a NumPy array? That's definitely what it's doing right now, pre-NumPy 1.17.

  4. jni commented on Jul 1, 2019

    @jni
    MemberAuthor

    Yes, that's right, we are merely testing for basic compatibility, ie that we won't barf with an error if a dask array is given as input. Which is exactly what we are en-route to doing at this point. 😂

  5. jni commented on Jul 2, 2019

    @jni
    MemberAuthor

    In response to a question by @hmaarrfk in #3987 about what we can do here: we could replace np.min by np.amin and it should go back to working as expected.

  6. jni commented on Jul 2, 2019

    @jni
    MemberAuthor

    (Or we can wait for rc2 which might fix the problem for us.)

  7. hmaarrfk commented on Jul 2, 2019

    @hmaarrfk
    Member

    That's definitely what it's doing right now, pre-NumPy 1.17.

    This comment from @shoyer makes it seem like it was a deliberate change.

  8. shoyer commented on Jul 2, 2019

    @shoyer

    I think this will be fixed shortly in a bug-fix release of dask -- see the linked issue for discussion. This operation will work (by using dask array operations), and other, non-implemented operations (e.g., np.median) will work but dask will issue a warning.

    But it is definitely true that at least some of these operations will start to be parallelized with dask rather than executed by automatic coercion into NumPy arrays. That will probably be a welcome change for skimage users, but it's definitely a change.

  9. jni commented on Jul 2, 2019

    @jni
    MemberAuthor

    @shoyer as I commented on the dask issue, that's only a partial fix, as it will still leave a whole bunch of incompatible NumPy/dask combinations out in the wild. The real fix is to have 1.17 issue a warning instead of a TypeError.

    That will probably be a welcome change for skimage users, but it's definitely a change.

    Yes, this is totally fine. The int() was actually added to make sure that it would continue to work in a future in which __array_function__ became a thing. It would be ideal for np.min to work correctly with array-function, but it should also work with intermediate versions of dask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions