MCPcopy Create free account
hub / github.com/numpy/numpy / gen_rst_table

Method gen_rst_table

doc/source/reference/simd/gen_features.py:116–132  ·  view source on GitHub ↗
(self, field_names, rows, tab_size=4)

Source from the content-addressed store, hash-verified

114 return self.gen_rst_table(fields, rows, **kwargs)
115
116 def gen_rst_table(self, field_names, rows, tab_size=4):
117 assert(not rows or len(field_names) == len(rows[0]))
118 rows.append(field_names)
119 fld_len = len(field_names)
120 cls_len = [max(len(c[i]) for c in rows) for i in range(fld_len)]
121 del rows[-1]
122 cformat = ' '.join('{:<%d}' % i for i in cls_len)
123 border = cformat.format(*['='*i for i in cls_len])
124
125 rows = [cformat.format(*row) for row in rows]
126 # header
127 rows = [border, cformat.format(*field_names), border] + rows
128 # footer
129 rows += [border]
130 # add left margin
131 rows = [(' ' * tab_size) + r for r in rows]
132 return '\n'.join(rows)
133
134def wrapper_section(title, content, tab_size=4):
135 tab = ' '*tab_size

Callers 1

gen_tableMethod · 0.95

Calls 2

maxFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected