@@ -3185,35 +3185,20 @@ def get_type(item, atype=int):
31853185 return atype
31863186
31873187 def get_justify (colname , column , precision ):
3188- ntype = type ( column [ 0 ])
3188+ ntype = column . dtype
31893189
3190- if (ntype == np .str or ntype == np .str_ or ntype == np .string0 or
3191- ntype == np .string_ ):
3192- length = max (len (colname ), column .itemsize )
3190+ if np .issubdtype (ntype , str ) or np .issubdtype (ntype , bytes ):
3191+ # The division below handles unicode stored in array, which could
3192+ # have 4 bytes per char
3193+ length = max (len (colname ), column .itemsize // column [0 ].itemsize )
31933194 return 0 , length + padding , "%s" # left justify
31943195
3195- if (ntype == np .int or ntype == np .int16 or ntype == np .int32 or
3196- ntype == np .int64 or ntype == np .int8 or ntype == np .int_ ):
3196+ if np .issubdtype (ntype , np .int ):
31973197 length = max (len (colname ),
31983198 np .max (list (map (len , list (map (str , column ))))))
31993199 return 1 , length + padding , "%d" # right justify
32003200
3201- # JDH: my powerbook does not have np.float96 using np 1.3.0
3202- """
3203- In [2]: np.__version__
3204- Out[2]: '1.3.0.dev5948'
3205-
3206- In [3]: !uname -a
3207- Darwin Macintosh-5.local 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun
3208- 9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386 i386
3209-
3210- In [4]: np.float96
3211- ---------------------------------------------------------------------------
3212- AttributeError Traceback (most recent call la
3213- """
3214- if (ntype == np .float or ntype == np .float32 or ntype == np .float64 or
3215- (hasattr (np , 'float96' ) and (ntype == np .float96 )) or
3216- ntype == np .float_ ):
3201+ if np .issubdtype (ntype , np .float ):
32173202 fmt = "%." + str (precision ) + "f"
32183203 length = max (
32193204 len (colname ),
0 commit comments