def test_possible_string_format_functions():
 t = QTable([([1, 2] * u.m)])
 t['col0'].info.format = '%.3f'
 assert (t.pformat() == [' col0', '  m  ', '-----', '1.000', '2.000'])
 t['col0'].info.format = 'hi {:.3f}'
 assert (t.pformat() == ['  col0  ', '   m    ', '--------', 'hi 1.000', 'hi 2.000'])
 t['col0'].info.format = '.4f'
 assert (t.pformat() == [' col0 ', '  m   ', '------', '1.0000', '2.0000'])

def test_possible_string_format_functions ( ) : t = QTable ( [ ( [ 1 , 2 ] * u . m ) ] ) t [ 'col0' ] . info . format = '%.3f' assert ( t . pformat ( ) == [ ' col0' , '  m  ' , '-----' , '1.000' , '2.000' ] ) t [ 'col0' ] . info . format = 'hi {:.3f}' assert ( t . pformat ( ) == [ '  col0  ' , '   m    ' , '--------' , 'hi 1.000' , 'hi 2.000' ] ) t [ 'col0' ] . info . format = '.4f' assert ( t . pformat ( ) == [ ' col0 ' , '  m   ' , '------' , '1.0000' , '2.0000' ] )
the quantityinfo info class for quantity implements a possible_string_format_functions() method that overrides the standard pprint .