Skip to content

Commit

Permalink
Add scripts to regenerate and sort pytest-mpl baselines.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed May 13, 2024
1 parent d20f2d8 commit 8027508
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions regen_mpl_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

tox -e py36 -- --mpl-generate-path=tests/baseline

tox -e py36 -- --mpl-generate-hash-library=image_hashes_36.json
tox -e py37 -- --mpl-generate-hash-library=image_hashes_37.json
tox -e py38 -- --mpl-generate-hash-library=image_hashes_38.json
tox -e py39 -- --mpl-generate-hash-library=image_hashes.json

python3 sort_hashes_json.py
37 changes: 37 additions & 0 deletions sort_hashes_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# stdlib
import json

expected_order = [
"tests.test_Display.test_plot_mass_spec_width",
"tests.test_Display.test_plot_ic",
"tests.test_Display.test_plot_tic",
"tests.test_Display.test_plot_ic_title",
"tests.test_Display.test_plot_ic_linestyle",
"tests.test_Display.test_plot_tic_linewidth",
"tests.test_Display.test_plot_mass_spec",
"tests.test_Display.test_plot_ic_multiple",
"tests.test_Display.test_plot_mass_spec_alpha",
"tests.test_Display.test_plot_tic_alpha",
"tests.test_Display.test_plot_tic_title",
"tests.test_Display.test_plot_tic_linestyle",
"tests.test_Display.test_plot_mass_spec_linestyle",
"tests.test_Display.test_plot_ic_label",
"tests.test_Display.test_plot_tic_label",
"tests.test_Display.test_plot_ic_alpha",
"tests.test_Display.test_plot_ic_linewidth",
"tests.test_Display.test_plot_mass_spec_title",
]

for filename in [
"tests/image_hashes_36.json",
"tests/image_hashes_37.json",
"tests/image_hashes_38.json",
"tests/image_hashes.json",
]:
with open(filename, encoding="UTF-8") as fp:
data = list(json.load(fp).items())

data.sort(key=lambda x: expected_order.index(x[0]))
with open(filename, 'w', encoding="UTF-8") as fp:
json.dump(dict(data), fp, indent=2)
fp.write('\n')

0 comments on commit 8027508

Please sign in to comment.