Skip to content

[0.14.1] Test failures with new numpy #3630

Closed

Description

@olebole

Description

I am trying to get the Debian skimage package working with the new numpy version. Apart from #3551 (where I backported #3556 for a fix), I get the following errors:

__________________________________ test_uint8 __________________________________
    def test_uint8():
        plt.figure()
        with expected_warnings(["tight_layout : falling back to Agg|\A\Z",
                                "CObject type is marked|\A\Z"]):
>           ax_im = io.imshow(im8)

skimage/io/tests/test_mpl_imshow.py:48: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/contextlib.py:24: in __exit__
    self.gen.next()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

matching = ['tight_layout : falling back to Agg|\\A\\Z', 'CObject type is marked|\\A\\Z']

    @contextmanager
    def expected_warnings(matching):
    """[...]"""
        if isinstance(matching, str):
            raise ValueError('``matching`` should be a list of strings and not '
                             'a string itself.')
        with all_warnings() as w:
            # enter context
            yield w
            # exited user context, check the recorded warnings
            # Allow users to provide None
            while None in matching:
                matching.remove(None)
            remaining = [m for m in matching if '\A\Z' not in m.split('|')]
            for warn in w:
                found = False
                for match in matching:
                    if re.search(match, str(warn.message)) is not None:
                        found = True
                        if match in remaining:
                            remaining.remove(match)
                if not found:
>                   raise ValueError('Unexpected warning: %s' % str(warn.message))
E                   ValueError: Unexpected warning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead

skimage/_shared/_warnings.py:127: ValueError

which repeats a number of times for different tests. It looks that the dependency warning is ignored here; however I don't find np.asscalar() used anywhere in the sources. And the stacktrace does not enlighten me where it could be generated.

These failures however currently prevent us from creating a bugfixed package.

Way to reproduce

  • Code example -- se above
  • Relevant images (if any) -- no
  • Operating system and version -- Debian unstable (sid)
  • Python version -- 2.7.15, numpy 1.16.0~rc1
  • scikit-image version (run skimage.__version__) 0.14.1

I'll attach the full build log.
skimage_0.14.1-3_amd64.build.gz

Activity

  1. hmaarrfk commented on Dec 30, 2018

    @hmaarrfk
    Member

    Thanks for looking into it. and the really detailed issue.

    Unfortunately, I can't seem to recreate the issue:

    pip list
    $ pip list                                                                                                                                                                                                         
    Package         Version     Location                    
    --------------- ----------- ----------------------------
    apipkg          1.5         
    atomicwrites    1.2.1       
    attrs           18.2.0      
    certifi         2018.11.29  
    cloudpickle     0.6.1       
    cycler          0.10.0      
    Cython          0.29.2      
    cytoolz         0.9.0.1     
    dask            1.0.0       
    decorator       4.3.0       
    execnet         1.5.0       
    imageio         2.4.1       
    kiwisolver      1.0.1       
    matplotlib      3.0.2       
    more-itertools  4.3.0       
    networkx        2.2         
    numpy           1.16.0rc1   
    olefile         0.46        
    Pillow          5.3.0       
    pip             18.1        
    pluggy          0.8.0       
    py              1.7.0       
    pyparsing       2.3.0       
    pytest          4.0.2       
    pytest-forked   0.2         
    pytest-xdist    1.25.0      
    python-dateutil 2.7.5       
    PyWavelets      1.0.1       
    scikit-image    0.14.2.dev0 /home/mark2/git/scikit-image
    scipy           1.1.0       
    setuptools      40.6.3      
    six             1.12.0      
    toolz           0.9.0       
    tornado         5.1.1       
    wheel           0.32.3
    

    Are you using any other --pre packages?

    I think this failure is pretty innocent. I wouldn't let it stop you from building the package.

    Things you can do:

    • remove (rename) the file skimage/io/tests/tests_mpl_imshow.py prior to testing (easy)
    mv skimage/io/tests/test_mpl_imshow.py skimage/io/tests/_test_mpl_imshow.py
    
    • Help debug it futher before our CIs reach the failure:
    • Apply this semi tested patch
    diff --git a/skimage/io/tests/test_mpl_imshow.py b/skimage/io/tests/test_mpl_imshow.py
    index 0e2ee441e..6197bc0e2 100644
    --- a/skimage/io/tests/test_mpl_imshow.py
    +++ b/skimage/io/tests/test_mpl_imshow.py
    @@ -44,7 +44,8 @@ def n_subplots(ax_im):
     def test_uint8():
         plt.figure()
         with expected_warnings(["tight_layout : falling back to Agg|\A\Z",
    -                            "CObject type is marked|\A\Z"]):
    +                            "CObject type is marked|\A\Z",
    +                            r"np.asscalar(a) is deprecated since NumPy|\A\Z"]):
             ax_im = io.imshow(im8)
         assert ax_im.cmap.name == 'gray'
         assert ax_im.get_clim() == (0, 255)

    Maybe for your package you can simply deselect the test
    These instructions didn't work for me!!!!
    https://docs.pytest.org/en/latest/example/pythoncollection.html#ignore-paths-during-test-collection
    https://docs.pytest.org/en/latest/example/pythoncollection.html#deselect-tests-during-test-collection

  2. hmaarrfk commented on Dec 30, 2018

    @hmaarrfk
    Member

    Here is the patch that would make your tests pass:
    https://github.com/scikit-image/scikit-image/commit/33960948f77ac5c208e917e84f8ee01adfa5b095.patch

    Also, I had trouble with dask 1.0.0

    but maybe you guys patched it?

    Get:51 http://ftp.de.debian.org/debian sid/main amd64 python3-dask all 1.0.0+dfsg-1 [497 kB]
    

    what is dfsg??

  3. olebole commented on Dec 30, 2018

    @olebole
    ContributorAuthor

    For the dask problem, see #3633. "+dfsg" means that some source that is not compatible to the Debian Free Source Guidelines was removed. Specifically these are the files docs/source/_static/profile.html and docs/source/_static/stacked_profile.html; so probably nothing important. There were other patches applied to dask, but they also seem to be safe.

  4. olebole commented on Dec 30, 2018

    @olebole
    ContributorAuthor

    The patch 3396094 still needs the |\A\Z, since the warnings do not appear on 3.7.

  5. hmaarrfk commented on Dec 30, 2018

    @hmaarrfk
    Member

    my dask issue was more with collecting the tests. Something a ufuncs.

    Thanks for catching the fact that the warning needed to be optional in certain locations. Here is the fixed up patch
    https://github.com/scikit-image/scikit-image/commit/2b8237e326e2f354d7178769b892e6cbad2c94fe.patch

  6. olebole commented on Dec 30, 2018

    @olebole
    ContributorAuthor

    I can confirm that 2b8237e works for this issue. Thank you!

  7. soupault commented on Jan 2, 2019

    @soupault
    Member

    Closed via #3632.

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