emmi_inference.common ===================== .. py:module:: emmi_inference.common Classes ------- .. autoapisummary:: emmi_inference.common.SaveFormat emmi_inference.common.DictMode Functions --------- .. autoapisummary:: emmi_inference.common.sanitize_suffix Module Contents --------------- .. py:class:: SaveFormat Bases: :py:obj:`str`, :py:obj:`enum.Enum` Supported on-disk formats for tensor outputs. Values: PYTORCH_PT: PyTorch serialized tensor/map (``.pt``). PYTORCH_TH: Alias, normalized to ``.pt``. PYTORCH_PTH: Alias, normalized to ``.pt``. NUMPY_NPY: NumPy array (``.npy``) for single tensors. NUMPY_NPZ: Compressed NumPy archive (``.npz``) for mappings. Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: PYTORCH_PT :value: 'pt' .. py:attribute:: PYTORCH_TH :value: 'th' .. py:attribute:: PYTORCH_PTH :value: 'pth' .. py:attribute:: NUMPY_NPY :value: 'npy' .. py:attribute:: NUMPY_NPZ :value: 'npz' .. py:method:: normalize(save_format) :classmethod: Return the canonical save format. :param save_format: A concrete `SaveFormat`. :returns: ``PYTORCH_PT`` when given ``PYTORCH_TH``/``PYTORCH_PTH``, otherwise the input value. :rtype: SaveFormat .. py:class:: DictMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` How to persist mapping outputs. Values: SPLIT: Write one file per key (suffix ``_key`` appended to the stem). SINGLE: Write a single container file containing all key/value pairs. Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: SPLIT :value: 'split' .. py:attribute:: SINGLE :value: 'single' .. py:function:: sanitize_suffix(suffix) Sanitize a suffix for safe filesystem usage. Replaces characters outside ``[A-Za-z0-9_-]`` with ``_``. :param suffix: Raw suffix text (e.g., a dictionary key). :returns: A filesystem-friendly suffix. :rtype: str