Skip to content

Table¤

Table ¤

Bases: ndarray

Represents the table element in an equipment register.

comment class-attribute instance-attribute ¤

comment: str = ''

A comment that is associated with the table.

header class-attribute instance-attribute ¤

header: NDArray[void] = empty(0, dtype=object)

The header value of each column.

types class-attribute instance-attribute ¤

types: NDArray[void] = empty(0, dtype=object)

The data type of each column.

units class-attribute instance-attribute ¤

units: NDArray[void] = empty(0, dtype=object)

The unit of each column.

__new__ ¤

__new__(
    *,
    types: NDArray[void],
    units: NDArray[void],
    header: NDArray[void],
    data: ArrayLike,
    comment: str = ""
) -> Table

Create a new Table instance.

Parameters:

Name Type Description Default
types NDArray[void]

The data type of each column.

required
units NDArray[void]

The unit of each column.

required
header NDArray[void]

The header value of each column.

required
data ArrayLike

The table data.

required
comment str

A comment that is associated with the table.

''

from_xml classmethod ¤

from_xml(element: Element[str]) -> Table

Convert an XML element into a Table instance.

Parameters:

Name Type Description Default
element Element[str]

A table XML element from an equipment register.

required

Returns:

Type Description
Table

A Table is an subclass of a numpy structured array, where the header is used as the field names. This allows for accessing a column by the header value rather than by the index of a column. If you prefer to work with unstructured data, call unstructured on the returned object.

to_xml ¤

to_xml() -> Element[str]

Convert the Table class into an XML element.

Returns:

Type Description
Element[str]

The Table as an XML element.

unstructured ¤

unstructured(
    *,
    dtype: DTypeLike = None,
    copy: bool = False,
    casting: Literal[
        "no", "equiv", "safe", "same_kind", "unsafe"
    ] = "unsafe"
) -> NDArray[Any]

Converts the structured array into an unstructured array.

If the table contains both numbers and strings, you may find that this method will fail.

See structured_to_unstructured for more details.

Warning

This returns a numpy ndarray instance (not a Table instance). The header, types, units and comment attributes are not included with the returned array.

Parameters:

Name Type Description Default
dtype DTypeLike

The dtype of the output unstructured array.

None
copy bool

If True, always return a copy. If False, a view is returned if possible.

False
casting Literal['no', 'equiv', 'safe', 'same_kind', 'unsafe']

See casting argument of numpy.ndarray.astype. Controls what kind of data casting may occur.

'unsafe'

Returns:

Type Description
NDArray[Any]

The unstructured array.