Discussion: Addition of figure tests using `pytest-mpl`

Open
#717 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
matplotlib, python

Research direction

Start by reviewing Stingray's existing tests that produce plots, then compare the proposed pytest-mpl approach with Astropy's figure_test helper and SunPy's reference-file strategy. Done means agreeing on a comparison or hash workflow and integrating figure verification with the test suite, including any required JSON or binary reference files.

Written by the indexing model from the issue text.

Description

Stingray's test suite produces a lot of plots, however, there are no tests comparing/verifying the plots to a previous version/hash.
This is supposed to be mitigated by other tests, but there can be issues which might manifest themselves into the end product itself (figures). Hence, the idea of verifying the plots to a previous binary/hash.

This can be solved by using pytest-mpl via either comparing the figure themselves or the figure hashes (preferred), as followed by astropy, sunpy, + and it's worth discussing if we want to implement a similar one in stingray, which I'll be happy to do.

The implementation will most likely be heavily inspired by astropy's figure_test, which uses a decorator and a JSON hash file inside the package for comparison.

Secondly, sunpy has a separate repo for storing ref binary files, which we can play it by the ear and implement if and when required.

Dominant language
Python
Stars
229
Forks
196
Avg merge
4d 12h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StingraySoftware/stingray

All issues in StingraySoftware/stingray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.