From c0a97a93fe4a2606a45eff926f412ceb3137762e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 20 Nov 2023 12:27:23 +0100 Subject: [PATCH] do not overwrite input, use specialized function --- python/damask/_colormap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index ad7aa286b..f4834da78 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -305,11 +305,11 @@ class Colormap(mpl.colors.ListedColormap): if abs(delta := r-l) * 1e8 <= (avg := 0.5*abs(r+l)): # delta is similar to numerical noise l,r = (l-0.5*avg*np.sign(delta),r+0.5*avg*np.sign(delta)) # extend range to have actual data centered within - field[np.isnan(field)] = (l+r)/2 + field_ = np.nan_to_num(field, nan=(l+r)/2, posinf=r, neginf=l) return Image.fromarray( (np.dstack(( - self.colors[np.round(np.clip((field-l)/(r-l),0.0,1.0)*(self.N-1)).astype(np.uint16),:3], + self.colors[np.round(np.clip((field_-l)/(r-l),0.0,1.0)*(self.N-1)).astype(np.uint16),:3], mask.astype(float) ) )*255