riptable.rt_meta

Classes

Doc

A document object containing metadata about a data object.

Info

A hierarchically structured container of descriptive information

Item

Descriptive information for a data object.

Functions

apply_schema(obj, schema[, doc])

Apply a schema containing descriptive information recursively to the

doc(obj)

Return the Doc for the object, describing its contents.

info(obj[, title])

Return the Info for the object, describing its contents.

class riptable.rt_meta.Doc(schema)

Bases: riptable.rt_struct.Struct

A document object containing metadata about a data object.

Parameters:

schema (dict) – See apply_schema() for more information on the format of the dictionary.

_descrip
_detail
_steward
_type
__repr__()

Return repr(self).

__str__()

Return str(self).

_as_info()
_repr_html_()
class riptable.rt_meta.Info

A hierarchically structured container of descriptive information for a data object.

description: str | None

The description of the data object.

Type:

str

detail

Detail about the data object.

Type:

str

items: List[Item] | None

For a Struct or Dataset, the items contained within it.

Type:

list of Item

steward: str | None

The steward of the data object.

Type:

str

title = []

The title of the data object

Type:

list

type: str | None

The type of the data object.

Type:

str

__repr__()

Return repr(self).

__str__()

Return str(self).

_make_text()
_repr_html_()
class riptable.rt_meta.Item(name, type, description, steward)

Descriptive information for a data object.

Parameters:
  • name (str) – The name of the data object.

  • type (str) – The type of the data object.

  • description (str) – A description of the data object.

  • steward (str) – The steward of the data object.

description: str

A description of the data object.

Type:

str

name: str

The name of the data object.

Type:

str

steward: str

The steward of the data object.

Type:

steward

type: str

The type of the data object.

Type:

str

riptable.rt_meta.apply_schema(obj, schema, doc=True)

Apply a schema containing descriptive information recursively to the input data object.

The schema should be in the form of a hierarchical dictionary, where for the data object, and recursively for each element it may contain, there is a descriptive dictionary with the following keys and values:

  • Type: ‘Struct’, ‘Dataset’, ‘Multiset’, ‘FastArray’, etc.

  • Description: a brief description of the data object

  • Steward: the name of the steward for that data object

  • Detail: any additional descriptive information

  • Contents: if the data object is a Struct, Dataset, or Multiset, a recursively formed dictionary where there is a descriptive dictionary of this form associated with the name of each element contained by the data object.

When the schema is applied to the data object, key/value pairs are set within the _meta dictionary attribute of the object and all of its elements, to enable subsequent retrieval of the descriptive information using the rt_struct.Struct.info() method or rt_struct.Struct.doc() property.

In addition, during the schema application process, the contents and type of each data object is compared to the expectation of the schema, with any differences returned in the form of a dictionary.

Parameters:
  • obj (Struct or FastArray) – The data object to apply the schema information to.

  • schema (dict) – A descriptive dictionary defining the schema that should apply to the data object and any elements it may contain.

  • doc (bool) – Indicates whether to create and attach a Doc to the object, so that the doc() method may be run on the object.

Returns:

res – Dictionary of deviations from the schema

Return type:

dict

riptable.rt_meta.doc(obj)

Return the Doc for the object, describing its contents.

Parameters:

obj (Any) – The object.

Returns:

doc – Returns a Doc instance if the object contains documentation metadata, otherwise None.

Return type:

Doc

riptable.rt_meta.info(obj, title=None)

Return the Info for the object, describing its contents.

Parameters:
  • obj (Any) – The object

  • title (str) – The title to give the object, defaults to None.

Returns:

info – Information about obj.

Return type:

Info