@@ -710,8 +710,8 @@ def fillFormat(self, data):
710
710
with errstate (all = 'ignore' ):
711
711
hasinf = isinf (data )
712
712
special = isnan (data ) | hasinf
713
- valid = not_equal ( data , 0 ) & ~ special
714
- non_zero = data [ valid ]
713
+ non_special = data [ ~ special ]
714
+ non_zero = non_special [ non_special != 0 ]
715
715
abs_non_zero = absolute (non_zero )
716
716
if len (non_zero ) == 0 :
717
717
max_val = 0.
@@ -727,7 +727,7 @@ def fillFormat(self, data):
727
727
or max_val / min_val > 1000. ):
728
728
self .exp_format = True
729
729
730
- if len (non_zero ) == 0 :
730
+ if len (non_special ) == 0 :
731
731
self .pad_left = 0
732
732
self .pad_right = 0
733
733
self .trim = '.'
@@ -740,7 +740,7 @@ def fillFormat(self, data):
740
740
trim , unique = 'k' , False
741
741
strs = (dragon4_scientific (x , precision = self .precision ,
742
742
unique = unique , trim = trim , sign = self .sign == '+' )
743
- for x in non_zero )
743
+ for x in non_special )
744
744
frac_strs , _ , exp_strs = zip (* (s .partition ('e' ) for s in strs ))
745
745
int_part , frac_part = zip (* (s .split ('.' ) for s in frac_strs ))
746
746
self .exp_size = max (len (s ) for s in exp_strs ) - 1
@@ -751,7 +751,7 @@ def fillFormat(self, data):
751
751
# for back-compatibility with np 1.13, use two spaces and full prec
752
752
if self ._legacy == '1.13' :
753
753
# undo addition of sign pos below
754
- will_add_sign = all (non_zero > 0 ) and self .sign == ' '
754
+ will_add_sign = all (non_special > 0 ) and self .sign == ' '
755
755
self .pad_left = 3 - will_add_sign
756
756
else :
757
757
# this should be only 1 or two. Can be calculated from sign.
@@ -769,7 +769,7 @@ def fillFormat(self, data):
769
769
fractional = True ,
770
770
unique = unique , trim = trim ,
771
771
sign = self .sign == '+' )
772
- for x in non_zero )
772
+ for x in non_special )
773
773
int_part , frac_part = zip (* (s .split ('.' ) for s in strs ))
774
774
self .pad_left = max (len (s ) for s in int_part )
775
775
self .pad_right = max (len (s ) for s in frac_part )
@@ -784,7 +784,7 @@ def fillFormat(self, data):
784
784
self .trim = '.'
785
785
786
786
# account for sign = ' ' by adding one to pad_left
787
- if len ( non_zero ) > 0 and all (non_zero > 0 ) and self .sign == ' ' :
787
+ if all (non_special >= 0 ) and self .sign == ' ' :
788
788
self .pad_left += 1
789
789
790
790
if any (special ):
0 commit comments