Skip to content

Intermittent Error in test_unwrap, part 2 #3237

Closed

Description

@hmaarrfk

Seems very related to #1197.
But this just happened on my machine again. I noticed that I had left a "skip if python 3.4" as it as happening then too.

__________________________________________test_wrap_around[3-1] __________________________________________
[gw6] linux -- Python 3.6.5 /home/mark/miniconda3/envs/skpre/bin/python

ndim = 3, axis = 1

    @skipif(sys.version_info[:2] == (3, 4),
            reason="Doesn't work with python 3.4. See issue #3079")
    @testing.parametrize("ndim, axis", dim_axis)
    def test_wrap_around(ndim, axis):
>       check_wrap_around(ndim, axis)

skimage/restoration/tests/test_unwrap.py:123: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ndim = 3, axis = 1

    def check_wrap_around(ndim, axis):
        # create a ramp, but with the last pixel along axis equalling the first
        elements = 100
        ramp = np.linspace(0, 12 * np.pi, elements)
        ramp[-1] = ramp[0]
        image = ramp.reshape(tuple([elements if n == axis else 1
                                    for n in range(ndim)]))
        image_wrapped = np.angle(np.exp(1j * image))
    
        index_first = tuple([0] * ndim)
        index_last = tuple([-1 if n == axis else 0 for n in range(ndim)])
        # unwrap the image without wrap around
        with warnings.catch_warnings():
            # We do not want warnings about length 1 dimensions
            warnings.simplefilter("ignore")
            image_unwrap_no_wrap_around = unwrap_phase(image_wrapped, seed=0)
        print('endpoints without wrap_around:',
              image_unwrap_no_wrap_around[index_first],
              image_unwrap_no_wrap_around[index_last])
        # without wrap around, the endpoints of the image should differ
        assert_(abs(image_unwrap_no_wrap_around[index_first] -
                    image_unwrap_no_wrap_around[index_last]) > np.pi)
        # unwrap the image with wrap around
        wrap_around = [n == axis for n in range(ndim)]
        with warnings.catch_warnings():
            # We do not want warnings about length 1 dimensions
            warnings.simplefilter("ignore")
            image_unwrap_wrap_around = unwrap_phase(image_wrapped, wrap_around,
                                                    seed=0)
        print('endpoints with wrap_around:',
              image_unwrap_wrap_around[index_first],
              image_unwrap_wrap_around[index_last])
        # with wrap around, the endpoints of the image should be equal
        assert_almost_equal(image_unwrap_wrap_around[index_first],
>                           image_unwrap_wrap_around[index_last])
E       AssertionError: 
E       Arrays are not almost equal to 7 decimals
E        ACTUAL: -12.566370614359172
E        DESIRED: 25.132741228718345

skimage/restoration/tests/test_unwrap.py:113: AssertionError
------------------------------------------ Captured stdout call ------------------------------------------
endpoints without wrap_around: -18.8495559215 18.8495559215
endpoints with wrap_around: -12.5663706144 25.1327412287

Activity

  1. cdluminate commented on Oct 17, 2018

    @cdluminate

    I encountered the same problem with python 3.6 and skimage 0.14.1

  2. hmaarrfk commented on Oct 17, 2018

    @hmaarrfk
    MemberAuthor

    Do you have an interpretation of what is going on?

  3. cdluminate commented on Oct 17, 2018

    @cdluminate

    @hmaarrfk No idea. I re-ran the test and the failure disappeared...

  4. hmaarrfk commented on Oct 17, 2018

    @hmaarrfk
    MemberAuthor

    Ah i thought maybe you encountered it in a meaningful data analysis pipeline.

  5. hmaarrfk commented on Oct 17, 2018

    @hmaarrfk
    MemberAuthor

    This is some issue with some pi phase wraparound:

    import numpy as np
    (25.132741228718345 + 12.566370614359172) / np.pi
    12.0
    
  6. rfezzani commented on Oct 18, 2021

    @rfezzani
    Member

    This seems fixed after dropping python < 3.6 support.

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