Skip to content

test_dpi_ratio_change fails on Windows/Qt5Agg #16123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kojoley opened this issue Jan 6, 2020 · 5 comments
Closed

test_dpi_ratio_change fails on Windows/Qt5Agg #16123

Kojoley opened this issue Jan 6, 2020 · 5 comments

Comments

@Kojoley
Copy link
Member

Kojoley commented Jan 6, 2020

================================== FAILURES ===================================
____________________________ test_dpi_ratio_change ____________________________
[gw0] win32 -- Python 3.6.7 c:\miniconda36-x64\envs\test-environment\python.exe
    @pytest.mark.backend('Qt5Agg')
    def test_dpi_ratio_change():
        """
        Make sure that if _dpi_ratio changes, the figure dpi changes but the
        widget remains the same physical size.
        """
    
        prop = 'matplotlib.backends.backend_qt5.FigureCanvasQT._dpi_ratio'
    
        with mock.patch(prop, new_callable=mock.PropertyMock) as p:
    
            p.return_value = 3
    
            fig = plt.figure(figsize=(5, 2), dpi=120)
            qt_canvas = fig.canvas
            qt_canvas.show()
    
            from matplotlib.backends.backend_qt5 import qApp
    
            # Make sure the mocking worked
            assert qt_canvas._dpi_ratio == 3
    
            size = qt_canvas.size()
    
            qt_canvas.manager.show()
            qt_canvas.draw()
            qApp.processEvents()
    
            # The DPI and the renderer width/height change
            assert fig.dpi == 360
            assert qt_canvas.renderer.width == 1800
            assert qt_canvas.renderer.height == 720
    
            # The actual widget size and figure physical size don't change
            assert size.width() == 600
            assert size.height() == 240
            assert qt_canvas.get_width_height() == (600, 240)
            assert (fig.get_size_inches() == (5, 2)).all()
    
            p.return_value = 2
    
            assert qt_canvas._dpi_ratio == 2
    
            qt_canvas.draw()
            qApp.processEvents()
            # this second processEvents is required to fully run the draw.
            # On `update` we notice the DPI has changed and trigger a
            # resize event to refresh, the second processEvents is
            # required to process that and fully update the window sizes.
            qApp.processEvents()
    
            # The DPI and the renderer width/height change
            assert fig.dpi == 240
            assert qt_canvas.renderer.width == 1200
>           assert qt_canvas.renderer.height == 480
E           assert 474.0 == 480
E            +  where 474.0 = <matplotlib.backends.backend_agg.RendererAgg object at 0x000000CC215AE2B0>.height

Build log: https://ci.appveyor.com/project/Kojoley/matplotlib/builds/29921850/job/1rdi7tiyqly53n3h

@QuLogic
Copy link
Member

QuLogic commented Jan 7, 2020

It's very flaky, fails for me locally too (not on Windows), and I'm not sure why.

@anntzer
Copy link
Contributor

anntzer commented Jan 7, 2020

At least locally on fedora it seems robust to me.

@jklymak
Copy link
Member

jklymak commented Dec 18, 2020

Did this get closed by #19123?

@Kojoley
Copy link
Member Author

Kojoley commented Dec 19, 2020

Just tested locally and the test runs fine now.

@Kojoley Kojoley closed this as completed Dec 19, 2020
@jklymak
Copy link
Member

jklymak commented Dec 19, 2020

Thanks a lot for checking!

@QuLogic QuLogic added this to the v3.4.0 milestone Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants