pytams.xmlutils

A set of utility for XML serializing.

Attributes

Exceptions

XMLUtilsError

Exception class for the xmlutils.

Functions

oneliner_ndarray(→ collections.abc.Generator[Any, ...)

Force ndarray print on a single line temporarily.

manual_cast_snapshot(→ Any)

Manually cast XML snapshot state.

manual_cast_snapshot_noise(→ Any)

Manually cast XML snapshot noise.

manual_cast(→ Any)

Manually cast XML elements reads.

manual_cast_str(→ Any)

Manually cast from strings.

dict_to_xml(→ xml.etree.ElementTree.Element)

Return an Element from a dictionnary.

xml_to_dict(→ dict[Any, Any])

Return an dictionnary an Element.

get_val_type(→ str)

Return the type of val.

new_element(→ xml.etree.ElementTree.Element)

Return an Element from two args.

make_xml_snapshot(→ xml.etree.ElementTree.Element)

Return a snapshot in XML elemt format.

read_xml_snapshot(→ tuple[float, float, Any, Any])

Return snapshot data from an XML snapshot elemt.

Module Contents

oneliner_ndarray() collections.abc.Generator[Any, None, None][source]

Force ndarray print on a single line temporarily.

exception XMLUtilsError[source]

Bases: Exception

Exception class for the xmlutils.

manual_cast_snapshot(elem: xml.etree.ElementTree.Element) Any[source]

Manually cast XML snapshot state.

manual_cast_snapshot_noise(elem: xml.etree.ElementTree.Element) Any[source]

Manually cast XML snapshot noise.

manual_cast(elem: xml.etree.ElementTree.Element) Any[source]

Manually cast XML elements reads.

POD_cast_dict: dict[str, collections.abc.Callable[Ellipsis, Any]][source]
manual_cast_str(type_str: str, elem_text: str) Any[source]

Manually cast from strings.

dict_to_xml(tag: str, d: dict[Any, Any]) xml.etree.ElementTree.Element[source]

Return an Element from a dictionnary.

Parameters:
  • tag – a root tag

  • d – a dictionary

xml_to_dict(elem: xml.etree.ElementTree.Element | None) dict[Any, Any][source]

Return an dictionnary an Element.

Parameters:

elem – an etree element

Returns:

a dictionary containing the element entries

get_val_type(val: Any) str[source]

Return the type of val.

Parameters:

val – a value

Returns:

val type

new_element(key: str, val: Any) xml.etree.ElementTree.Element[source]

Return an Element from two args.

Parameters:
  • key – the element key

  • val – the element value

Returns:

an ElementTree element

make_xml_snapshot(idx: int, time: float, score: float, noise: Any, state: Any) xml.etree.ElementTree.Element[source]

Return a snapshot in XML elemt format.

Parameters:
  • idx – snapshot index

  • time – the time stamp

  • score – the snapshot score function

  • noise – the stochastic noise

  • state – the associated state

read_xml_snapshot(snap: xml.etree.ElementTree.Element) tuple[float, float, Any, Any][source]

Return snapshot data from an XML snapshot elemt.

Parameters:

snap – an XML snapshot elemt