@@ -3185,35 +3185,20 @@ def get_type(item, atype=int):
3185
3185
return atype
3186
3186
3187
3187
def get_justify (colname , column , precision ):
3188
- ntype = type ( column [ 0 ])
3188
+ ntype = column . dtype
3189
3189
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 )
3193
3194
return 0 , length + padding , "%s" # left justify
3194
3195
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 ):
3197
3197
length = max (len (colname ),
3198
3198
np .max (list (map (len , list (map (str , column ))))))
3199
3199
return 1 , length + padding , "%d" # right justify
3200
3200
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 ):
3217
3202
fmt = "%." + str (precision ) + "f"
3218
3203
length = max (
3219
3204
len (colname ),
0 commit comments