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: array :
numpy.ndarrayA record array to print.
filename :
stror file-like, optionalIf supplied, write to this file.
formatcodes :
dict, optionalIf supplied, use explicit format for certain columns.
alias :
dict, optionalIf supplied, use this mapping of record array column names to printed column names.
fdigit :
int, optionalWidth of 32-bit floating point columns, default 5.
ddigit :
int, optionalWidth of 64-bit floating point columns, default 7.
html :
bool, optionalIf
True, print an html table.no_head :
bool, optionalIf
True, don’t print a header line.silent :
bool, optionalIf
True, do not print the table, just return it.Returns: tuple()A tuple containing a list of the lines in the table. If
htmlisTrue, 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 '], [])