From 7d49606597e76fc56944cf5bf36f5000577845a2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 4 Aug 2020 20:34:40 +0200 Subject: [PATCH] restored correct bound calculation test different bounds options --- python/damask/_colormap.py | 2 +- python/tests/reference/Colormap/shade.png | Bin 143 -> 0 bytes python/tests/reference/Colormap/shade_None.png | Bin 0 -> 146 bytes python/tests/reference/Colormap/shade_[2, 10].png | Bin 0 -> 136 bytes python/tests/test_Colormap.py | 9 +++++---- 5 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 python/tests/reference/Colormap/shade.png create mode 100644 python/tests/reference/Colormap/shade_None.png create mode 100644 python/tests/reference/Colormap/shade_[2, 10].png diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 8bcb076d4..5c0ca11d3 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -186,7 +186,7 @@ class Colormap(mpl.colors.ListedColormap): np.logical_or (np.isnan(field), field == gap)) # mask gap and NaN (if gap present) if bounds is None: - hi,lo = field[mask].min(),field[mask].max() + hi,lo = field[mask].max(),field[mask].min() else: hi,lo = bounds[::-1] diff --git a/python/tests/reference/Colormap/shade.png b/python/tests/reference/Colormap/shade.png deleted file mode 100644 index a9e5eacea012a542f6f2ce8996be96d34f917f7a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^+(695!3HFgJ}hYlQemDhjv*CudQVw%H5dpu9GreM zg2O2!$u8&Iqrd)3TRSoqT7TVfcH`$qOOs{QKgp~pT=>jIi*@6%6~E5J8*V9kzTYC| orbwt@_LA=%rc7Wo@1_JJA19Zn_gU_y9H0#hp00i_>zopr0366ORsaA1 diff --git a/python/tests/reference/Colormap/shade_None.png b/python/tests/reference/Colormap/shade_None.png new file mode 100644 index 0000000000000000000000000000000000000000..2289910ae27a5d96cd99cf2400367fd8afa9a311 GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^+(695!3HFgJ}hYlQjwl6jv*CudQTnXZE)alJ*fWo z`wGz+2hwkbCU0SVW^=pp&HZIhCRg08RN8STQt%8%8@qF(Q-pb%+O^(OM|K4+-jH`@ uR)qN~AlFj-TJKK1HPWx+BFy`i|6pvLX89&|fmz9*vXDv2;edFxsq+4aDKW>ecpX&CfSZLuTj;U@d lOq`YqYV`(WwsT literal 0 HcmV?d00001 diff --git a/python/tests/test_Colormap.py b/python/tests/test_Colormap.py index 8eebf63ee..b3309f12b 100644 --- a/python/tests/test_Colormap.py +++ b/python/tests/test_Colormap.py @@ -131,13 +131,14 @@ class TestColormap: c += c assert (np.allclose(c.colors[:len(c.colors)//2],c.colors[len(c.colors)//2:])) - def test_shade(self,reference_dir,update): + @pytest.mark.parametrize('bounds',[None,[2,10]]) + def test_shade(self,reference_dir,update,bounds): data = np.add(*np.indices((10, 11))) - img_current = Colormap.from_predefined('orientation').shade(data) + img_current = Colormap.from_predefined('orientation').shade(data,bounds=bounds) if update: - img_current.save(reference_dir/'shade.png') + img_current.save(reference_dir/f'shade_{bounds}.png') else: - img_reference = Image.open(reference_dir/'shade.png') + img_reference = Image.open(reference_dir/f'shade_{bounds}.png') diff = ImageChops.difference(img_reference.convert('RGB'),img_current.convert('RGB')) assert not diff.getbbox()