@@ -367,10 +367,11 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
367367 # need to
368368
369369 # TODO slice input array first
370-
371- # make a working array up here, re-use twice to save memory
372- working_array = np .empty (A .shape , dtype = np .float32 )
373-
370+ inp_dtype = A .dtype
371+ if inp_dtype .kind == 'f' :
372+ scaled_dtype = A .dtype
373+ else :
374+ scaled_dtype = np .float32
374375 a_min = np .nanmin (A )
375376 a_max = np .nanmax (A )
376377 # scale the input data to [.1, .9]. The Agg
@@ -380,7 +381,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
380381 # over / under.
381382 # This may introduce numeric instabilities in very broadly
382383 # scaled data
383- A_scaled = working_array
384+ A_scaled = np . empty ( A . shape , dtype = scaled_dtype )
384385 A_scaled [:] = A
385386 A_scaled -= a_min
386387 A_scaled /= ((a_max - a_min ) / 0.8 )
@@ -410,7 +411,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
410411 if isinstance (self .norm , mcolors .NoNorm ):
411412 A_resampled = A_resampled .astype (A .dtype )
412413
413- mask = working_array
414+ mask = np . empty ( A . shape , dtype = np . float32 )
414415 if A .mask .shape == A .shape :
415416 # this is the case of a nontrivial mask
416417 mask [:] = np .where (A .mask , np .float32 (np .nan ),
0 commit comments