@@ -30,15 +30,7 @@ def __init__(self, array, out_dtype=None)
3030"""
3131import numpy as np
3232
33- from .casting import (
34- as_int ,
35- best_float ,
36- floor_exact ,
37- int_abs ,
38- int_to_float ,
39- shared_range ,
40- type_info ,
41- )
33+ from .casting import best_float , floor_exact , int_abs , int_to_float , shared_range , type_info
4234from .volumeutils import array_to_file , finite_range
4335
4436
@@ -152,9 +144,8 @@ def scaling_needed(self):
152144 # No scaling needed if data already fits in output type
153145 # But note - we need to convert to ints, to avoid conversion to float
154146 # during comparisons, and therefore int -> float conversions which are
155- # not exact. Only a problem for uint64 though. We need as_int here to
156- # work around a numpy 1.4.1 bug in uint conversion
157- if as_int (mn ) >= as_int (info .min ) and as_int (mx ) <= as_int (info .max ):
147+ # not exact. Only a problem for uint64 though.
148+ if int (mn ) >= int (info .min ) and int (mx ) <= int (info .max ):
158149 return False
159150 return True
160151
@@ -392,7 +383,7 @@ def _do_scaling(self):
392383 out_max , out_min = info .max , info .min
393384 # If left as int64, uint64, comparisons will default to floats, and
394385 # these are inexact for > 2**53 - so convert to int
395- if as_int (mx ) <= as_int (out_max ) and as_int (mn ) >= as_int (out_min ):
386+ if int (mx ) <= int (out_max ) and int (mn ) >= int (out_min ):
396387 # already in range
397388 return
398389 # (u)int to (u)int scaling
@@ -410,7 +401,7 @@ def _iu2iu(self):
410401 # that deals with max neg ints. abs problem only arises when all
411402 # the data is set to max neg integer value
412403 o_min , o_max = shared_range (self .scaler_dtype , out_dt )
413- if mx <= 0 and int_abs (mn ) <= as_int (o_max ): # sign flip enough?
404+ if mx <= 0 and int_abs (mn ) <= int (o_max ): # sign flip enough?
414405 # -1.0 * arr will be in scaler_dtype precision
415406 self .slope = - 1.0
416407 return
@@ -546,14 +537,13 @@ def to_fileobj(self, fileobj, order='F'):
546537
547538 def _iu2iu (self ):
548539 # (u)int to (u)int
549- mn , mx = (as_int (v ) for v in self .finite_range ())
540+ mn , mx = (int (v ) for v in self .finite_range ())
550541 # range may be greater than the largest integer for this type.
551- # as_int needed to work round numpy 1.4.1 int casting bug
552542 out_dtype = self ._out_dtype
553543 # Options in this method are scaling using intercept only. These will
554544 # have to pass through ``self.scaler_dtype`` (because the intercept is
555545 # in this type).
556- o_min , o_max = (as_int (v ) for v in shared_range (self .scaler_dtype , out_dtype ))
546+ o_min , o_max = (int (v ) for v in shared_range (self .scaler_dtype , out_dtype ))
557547 type_range = o_max - o_min
558548 mn2mx = mx - mn
559549 if mn2mx <= type_range : # might offset be enough?
@@ -565,12 +555,12 @@ def _iu2iu(self):
565555 else : # int output - take midpoint to 0
566556 # ceil below increases inter, pushing scale up to 0.5 towards
567557 # -inf, because ints have abs min == abs max + 1
568- midpoint = mn + as_int (np .ceil (mn2mx / 2.0 ))
558+ midpoint = mn + int (np .ceil (mn2mx / 2.0 ))
569559 # Floor exact decreases inter, so pulling scaled values more
570560 # positive. This may make mx - inter > t_max
571561 inter = floor_exact (midpoint , self .scaler_dtype )
572562 # Need to check still in range after floor_exact-ing
573- int_inter = as_int (inter )
563+ int_inter = int (inter )
574564 assert mn - int_inter >= o_min
575565 if mx - int_inter <= o_max :
576566 self .inter = inter
@@ -598,7 +588,7 @@ def _range_scale(self, in_min, in_max):
598588 # same as double so in_range will be 2**64 - thus overestimating
599589 # slope slightly. Casting to int needed to allow in_max-in_min to
600590 # be larger than the largest (u)int value
601- in_min , in_max = as_int (in_min ), as_int (in_max )
591+ in_min , in_max = int (in_min ), int (in_max )
602592 in_range = int_to_float (in_max - in_min , big_float )
603593 # Cast to float for later processing.
604594 in_min , in_max = (int_to_float (v , big_float ) for v in (in_min , in_max ))
0 commit comments