You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The previous issue #46 demonstrates that unit tests that compare graphical output should be addressed.
One taks is to make a separate comparison function, used by tests, that can compare the generated plots with base line plots. This has been tried earlier but the tests need some kind of tolerance due to subtle library changes (and possibly differences between os)
E.g. (via Copilot):
# conftest.py
import os
from PIL import Image
from skimage.metrics import structural_similarity as compare_ssim
import numpy as np
def compare_plots(generated_plot_path, reference_plot_path, threshold=0.95):
"""
Compare two plots using Structural Similarity Index (SSIM).
:param generated_plot_path: Path to the generated plot.
:param reference_plot_path: Path to the reference plot.
:param threshold: SSIM threshold to consider images approximately equal.
:return: None. Raises AssertionError if plots are not approximately equal.
"""
# Load the images
generated_image = Image.open(generated_plot_path).convert('L')
reference_image = Image.open(reference_plot_path).convert('L')
# Convert images to numpy arrays
generated_image_np = np.array(generated_image)
reference_image_np = np.array(reference_image)
# Compute the Structural Similarity Index (SSIM) between the images
ssim_index, _ = compare_ssim(generated_image_np, reference_image_np, full=True)
print("SSIM index:", ssim_index)
# Assert that the SSIM index is above the threshold
assert ssim_index > threshold, "The plot has changed significantly!"
The text was updated successfully, but these errors were encountered:
jcrivenaes
changed the title
More tests on graphical comparsions
More tests on graphical comparisons
Sep 16, 2024
The previous issue #46 demonstrates that unit tests that compare graphical output should be addressed.
One taks is to make a separate comparison function, used by tests, that can compare the generated plots with base line plots. This has been tried earlier but the tests need some kind of tolerance due to subtle library changes (and possibly differences between os)
E.g. (via Copilot):
The text was updated successfully, but these errors were encountered: