Skip to content
Snippets Groups Projects
Commit 9656e5de authored by Véronique  LEGRAND's avatar Véronique LEGRAND
Browse files

changed test_global_plot to used pillow and numpy for image comparison

parent 46ad7c44
No related branches found
No related tags found
2 merge requests!108Fixing py 3.12,!107Draft: changed the loading of data required to draw the global plot; now read only 3...
......@@ -3,8 +3,10 @@
from __future__ import absolute_import
import os, shutil, tempfile
from pathlib import Path
import matplotlib as plt
from jass.models import plots
from PIL import Image
import numpy as np
from . import JassTestCase
......@@ -13,6 +15,7 @@ class TestPlots(JassTestCase):
test_folder = "data_real"
expected_res_folder = "expected_graphs"
#expected_res_folder="baseline_images/test_plot"
def setUp(self):
# Create a temporary directory
......@@ -26,15 +29,23 @@ class TestPlots(JassTestCase):
pass
def test_create_global_plot(self):
#import shutil
#print(plt.rcParams)
plots.create_global_plot(self.worktable_hdf_path, self.test_dir / "global_plot.png")
#plots.create_global_plot(self.worktable_hdf_path, "/Users/vlegrand/tmp/global_plot.png")
fnew=open(self.test_dir / "global_plot.png",'rb')
fref=open(self.ref_res_dir / "expected_global_plot.png",'rb')
content_new=fnew.read()
content_ref=fref.read()
assert(content_new==content_ref)
fnew.close()
fref.close()
img_new=Image.open(self.test_dir /"global_plot.png")
#fnew=open(self.test_dir / "global_plot.png",'rb')
#fref=open(self.ref_res_dir / "expected_global_plot.png",'rb')
img_ref=Image.open(self.ref_res_dir / "expected_global_plot.png")
sum_sq_diff = np.sum((np.asarray(img_new).astype('float') - np.asarray(img_ref).astype('float')) ** 2)
print("sum_sq_diff=",sum_sq_diff)
assert(sum_sq_diff==0.0)
#content_new=fnew.read()
#content_ref=fref.read()
shutil.copyfile(self.test_dir / "global_plot.png","/pasteur/gaia/homes/vlegrand/global_plot.png")
#assert(content_new==content_ref)
#fnew.close()
#fref.close()
def test_create_qq_plot(self):
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment