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