perun.io.util ============= .. py:module:: perun.io.util .. autoapi-nested-parse:: IO Util. Classes ------- .. autoapisummary:: perun.io.util.NumpyEncoder Functions --------- .. autoapisummary:: perun.io.util.getTFactorMag perun.io.util.value2ValueUnitStr perun.io.util.value2MeanStdStr Module Contents --------------- .. py:function:: getTFactorMag(value: perun.data_model.measurement_type.Number, metric_md: perun.data_model.measurement_type.MetricMetaData) -> Tuple[float, perun.data_model.measurement_type.Magnitude] Get transformation factor and magnitude to improve string formating. :param value: Reference value :type value: Number :param metric_md: Value description :type metric_md: MetricMetaData :returns: Scaling factor and Magnitude Enum :rtype: Tuple[float, Magnitude] .. py:function:: value2ValueUnitStr(value: perun.data_model.measurement_type.Number, metric_md: perun.data_model.measurement_type.MetricMetaData) -> str Return a printable representation as [Value:.3f][mag][unit] (e.g. 3.05mV) of the value based on its metric metadata. :param value: Value to apply formating to. :type value: Number :param metric_md: Value metadata. :type metric_md: MetricMetaData :returns: String represenation :rtype: str .. py:function:: value2MeanStdStr(stats: perun.data_model.data.Stats) -> str Return a printable representation as [Value:.3f]±[std:.3f][mag][unit] (e.g. 3.05±0.1mV) of the value based on its metric metadata. :param stats: Stats to apply formating to. :type stats: Stats obj :param metric_md: Value metadata. :type metric_md: MetricMetaData :returns: String represenation :rtype: str .. py:class:: NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None) Bases: :py:obj:`json.JSONEncoder` Json Numpy object encoder. .. py:method:: default(obj: Any) -> Any Encode an object to a JSON-serializable format, handling NumPy types. :param obj: The object to encode. :type obj: Any :returns: The JSON-serializable representation of the input object. :rtype: Any :raises TypeError: If the object cannot be encoded to a supported format. .. rubric:: Notes This method specifically handles NumPy integer, floating, ndarray, and dtype objects, converting them to standard Python types or string representations. For other types, the superclass's default method is called.