Git Product home page Git Product logo

Comments (2)

nathanshammah avatar nathanshammah commented on August 16, 2024 1

This looks like a nontrivial challenge, glad that you're putting thought in it. Having a quick look around, it looks like Matplotlib uses a decorator for this, image_comparison, within a full testing module devoted to such comparisons.

from qsurface.

watermarkhu avatar watermarkhu commented on August 16, 2024

This problem is even harder than I imagined. The figures in opensurfacesim are interactive and utilizes the Tkinter framework, which is loaded by matplotlib.use('TkAgg'). By loading the tk framework, each figure window is effectively a Tkinter GUI. The problem that many encounter is that the test suite waits until the GUI window is closed.

The way I see it, the testing of the plotting features can be performed in two ways.

  1. Direct comparison with saved images. This is what the image_comparison decorator from matplotlib does.
  2. Testing by only asserting an error has occurred if an exception is raised.

Since plotting in opensurfacesim is highly dynamic, the second method might be preferable. The current implementation utilizes a custom matplotlib.blocking_input object for which we can alter the waiting time. If the waiting time is set to 0, the problem described above is avoided. Currently, testing functions for a large amount of the plotting features is already bundled under the @pytest.mark.plotting mark, and we can successfully perform these tests, locally.

For CI, since there is no DISPLAY or renderer for the GUI, calling matplotlib.use('TkAgg') becomes quite problematic. More investigation into this matter is needed. A possible solution is to use a Xvfb framebuffer, which also has a pytest integration.

from qsurface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.