struct_print

pydl.pydlutils.misc.struct_print(array, filename=None, formatcodes=None, alias=None, fdigit=5, ddigit=7, html=False, no_head=False, silent=False)[source]

Print a NumPy record array (analogous to an IDL structure) in a nice way.

Parameters
arraynumpy.ndarray

A record array to print.

filenamestr or file-like, optional

If supplied, write to this file.

formatcodesdict, optional

If supplied, use explicit format for certain columns.

aliasdict, optional

If supplied, use this mapping of record array column names to printed column names.

fdigitint, optional

Width of 32-bit floating point columns, default 5.

ddigitint, optional

Width of 64-bit floating point columns, default 7.

htmlbool, optional

If True, print an html table.

no_headbool, optional

If True, don’t print a header line.

silentbool, optional

If True, do not print the table, just return it.

Returns
tuple

A tuple containing a list of the lines in the table. If html is True, also returns a list of lines of CSS for formatting the table.

Examples

>>> import numpy as np
>>> from pydl.pydlutils.misc import struct_print
>>> struct_print(np.array([(1,2.34,'five'),(2,3.456,'seven'),(3,4.5678,'nine')],dtype=[('a','i4'),('bb','f4'),('ccc','S5')]),silent=True)
(['a bb          ccc  ', '- ----------- -----', '1        2.34 five ', '2       3.456 seven', '3      4.5678 nine '], [])