DataInfo#

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 https://nbviewer.jupyter.org/urls/gist.github.com/ChrisBeaumont/5758381/raw/descriptor_writeup.ipynb for this trick that works for non-hashable classes.

Parameters:
boundbool

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

attr_names

attrs_from_parent

description

dtype

format

meta

name

unit

Methods Summary

__call__([option, out])

Write summary information about data object to the out filehandle.

info_summary_attributes(dat)

info_summary_stats(dat)

Attributes Documentation

attr_names = {'description', 'dtype', 'format', 'meta', 'name', 'unit'}#
attrs_from_parent = {}#
description#
dtype#
format#
meta#
name#
unit#

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.

Parameters:
optionstr, callable(), list of (str or callable())

Info option, defaults to ‘attributes’.

outfile-like object, None

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

Returns:
infoOrderedDict or None

OrderedDict if out==None else None

Examples

>>> from astropy.table import Column
>>> c = Column([1, 2], unit='m', dtype='int32')
>>> c.info()
dtype = int32
unit = m
class = Column
n_bad = 0
length = 2
>>> c.info(['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)#