class astropy.utils.data_info.DataInfo(bound=False)[source]

Bases: object

Descriptor that data classes use to add an info attribute for storing data attributes in a uniform and portable way. Note that it must be called info so that the DataInfo() object can be stored in the instance using the info key. Because owner_cls.x is a descriptor, Python doesn’t use __dict__[‘x’] normally, and the descriptor can safely store stuff there. Thanks to for this trick that works for non-hashable classes.

bound : bool

If True this is a descriptor attribute in a class definition, else it is a DataInfo() object that is bound to a data object instance. Default is False.

Attributes Summary


Methods Summary

__call__([option, out]) Write summary information about data object to the out filehandle.

Attributes Documentation

attr_names = {'dtype', 'meta', 'unit', 'format', 'name', 'description'}
attrs_from_parent = set()

Methods Documentation

__call__(option='attributes', out='')[source]

Write summary information about data object to the out filehandle. By default this prints to standard output via sys.stdout.

The option argument specifies what type of information to include. This can be a string, a function, or a list of strings or functions. Built-in options are:

  • attributes: data object attributes like dtype and format
  • stats: basic statistics: min, mean, and max

If a function is specified then that function will be called with the data object as its single argument. The function must return an OrderedDict containing the information attributes.

If a list is provided then the information attributes will be appended for each of the options, in order.

option : str, function, list of (str or function)

Info option, defaults to ‘attributes’.

out : file-like object, None

Output destination, defaults to sys.stdout. If None then the OrderedDict with information attributes is returned

info : OrderedDict if out==None else None


>>> from astropy.table import Column
>>> c = Column([1, 2], unit='m', dtype='int32')
dtype = int32
unit = m
class = Column
n_bad = 0
length = 2
>>>['attributes', 'stats'])
dtype = int32
unit = m
class = Column
mean = 1.5
std = 0.5
min = 1
max = 2
n_bad = 0
length = 2
static info_summary_attributes(dat)
static info_summary_stats(dat)