pyrevs.utils.yamlutils ====================== .. py:module:: pyrevs.utils.yamlutils Classes ------- .. autoapisummary:: pyrevs.utils.yamlutils.PTDumper Functions --------- .. autoapisummary:: pyrevs.utils.yamlutils.ndarray_representer pyrevs.utils.yamlutils.tuple_representer pyrevs.utils.yamlutils.append_trajectory_to_yaml pyrevs.utils.yamlutils.load_trajectories_from_yaml Module Contents --------------- .. py:class:: PTDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True) Bases: :py:obj:`yaml.SafeDumper` Custom Dumper to handle numpy types and python-specific structures. .. py:function:: ndarray_representer(dumper: yaml.SafeDumper, data: numpy.typing.NDArray[numpy.number]) -> yaml.nodes.MappingNode Convert numpy arrays to a list + metadata for YAML. .. py:function:: tuple_representer(dumper: yaml.SafeDumper, data: tuple[Any, Ellipsis]) -> yaml.nodes.SequenceNode Ensure tuples are preserved as tuples, not lists. .. py:function:: append_trajectory_to_yaml(filepath: str, traj_data: dict) -> None Appends a single trajectory to a YAML file. Each trajectory is its own 'document' in the stream. .. py:function:: load_trajectories_from_yaml(filepath: str) -> collections.abc.Generator[Any, None, None] A generator that yields trajectories one by one. This prevents loading a massive ensemble file into RAM at once.