@@ -367,10 +367,11 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
367
367
# need to
368
368
369
369
# 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
374
375
a_min = np .nanmin (A )
375
376
a_max = np .nanmax (A )
376
377
# 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,
380
381
# over / under.
381
382
# This may introduce numeric instabilities in very broadly
382
383
# scaled data
383
- A_scaled = working_array
384
+ A_scaled = np . empty ( A . shape , dtype = scaled_dtype )
384
385
A_scaled [:] = A
385
386
A_scaled -= a_min
386
387
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,
410
411
if isinstance (self .norm , mcolors .NoNorm ):
411
412
A_resampled = A_resampled .astype (A .dtype )
412
413
413
- mask = working_array
414
+ mask = np . empty ( A . shape , dtype = np . float32 )
414
415
if A .mask .shape == A .shape :
415
416
# this is the case of a nontrivial mask
416
417
mask [:] = np .where (A .mask , np .float32 (np .nan ),
0 commit comments