Format ====== .. py:class:: Format(fmt: str, engine: ansys.modelcenter.workflow.grpc_modelcenter.engine.Engine) :canonical: ansys.modelcenter.workflow.grpc_modelcenter.format.Format Bases: :py:obj:`ansys.modelcenter.workflow.api.IFormat` Provides the formatter for converting between strings and values. .. note:: This class should not be directly instantiated by clients. Create an ``Engine`` instance and use it to get a valid instance of this object. .. !! processed by numpydoc !! Overview -------- .. py:currentmodule:: Format .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~string_to_integer` - Convert a formatted string to an integer. * - :py:attr:`~string_to_real` - Convert a formatted string to a real value. * - :py:attr:`~integer_to_string` - Convert an integer to a formatted string. * - :py:attr:`~real_to_string` - Convert a real value to a formatted string. * - :py:attr:`~string_to_string` - Convert an unformatted string to a formatted string. * - :py:attr:`~integer_to_editable_string` - Convert an integer to an editable formatted string representation. * - :py:attr:`~real_to_editable_string` - Convert a real value to an editable formatted string representation. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~format` - Style to use for formatting. Import detail ------------- .. code-block:: python from ansys.modelcenter.workflow.grpc_modelcenter.format import Format Property detail --------------- .. py:property:: format :canonical: ansys.modelcenter.workflow.grpc_modelcenter.format.Format.format :type: str Style to use for formatting. Formats, with the exception of dates, mimic the formatting style used in Microsoft Excel. However, they are not a one-to-one match, so there are some differences. There are several broad categories of formats: - **No specific format** Specified by ``General`` or an empty string, this is the default format intended to cover most non-specific cases. It shows a limited number of significant figures and automatically switches between number and scientific formats based on the number's scale. - **Number** Number formats are used for specifying how numeric values are displayed. For specialized handling of monetary values, see the **Currency** format. Specification: * Zero decimal places are indicated by ``0``. * 1 to 30 decimal places are indicated by ``0.0`` with an extra trailing zero for each decimal place. * Use of a 1000's separator is indicated by leading ``#,##``. * Negative sign can be switched to surrounding braces by surrounding the entire expression with braces. Examples: * ``0.00``: Two decimal places * ``(#,##0.00000)``: Negative braces, 1000's separator, five decimal places - **Currency** Currency formats are for general monetary values. Specification: * Follows the **Number** format for specifying digits, but starts with a ``$`` symbol. If negative braces are specified, the symbol should be within them. * The 1000's separator is required. If it is missing, it is added automatically. Examples: * ``$#,##0.00``: Two decimal places. * ``($#,##0.00000)``: Negative braces, five decimal places. - **Percentage** Percentage formats multiply the datapin value by 100 and display the result with a percent sign. Specification: * Follows the **Number** format for specifying number of digits, but ends with a ``%`` symbol. * No 1000's separator or negative braces are allowed. Examples: * ``0.00%``: Two decimal places. * ``0.00000%``: Five decimal places. - **Fraction** Fraction formats show the value as a fraction. Specification: * Only certain arbitrary combinations are allowed. See the examples. Examples: * ``# ?/?``: Up to one digit. * ``# ??/??``: Up to two digits. * ``# ???/???``: Up to three digits. * ``# ?/2``: As halves. * ``# ?/4``: As quarters. * ``# ?/8``: As eighths. * ``# ??/16``: As sixteenths. * ``# ?/10``: As tenths. * ``# ??/100``: As hundredths. - **Scientific** Scientific formats show the value in scientific notation. Specification: * Follows the **Number** format for specifying digits but ends with the string '`E+00'`. Examples: * ``0.00E+00``: Two decimal places. * ``0.00000E+00``: Five decimal places. - **Date** Date formats show the value as a date. Specification: * Specified by certain strings. See the examples. Examples: Date formats follow with example outputs. * Epoch formats: * ``EpSec``: 0 * ``EpMin``: 0.00000 * ``EpHr``: 0.0000000 * ``EpDay``: 0.00000000 * ``EpYr``: 0.00000000000 * Standard display formats: * ``DD/MM/YYY``: 31/21/1971 00:00:00.000 * ``YYDDD``: 71365.00000000 * ``YYYYDDD``: 1971365.000000 * ``YYYYMMDD``: 19711231.00000000 * ``YYYY/MM/DD``: 1971/12/31 00:00:00.000 * ``YYYY:MM:DD``: 1971:12:31:00:00:00.000 * Gregorian formats: * ``GPSG``: 30 Dec 1971 23:59:51.000 * ``LCLG``: 30 Dec 1971 20:00:00.000 * ``TAIG``: 31 Dec 1971 00:00:10.000 * ``TDBG``: 31 Dec 1971 00:00:42.184 * ``TDTG``: 31 Dec 1971 00:00:42.184 * ``UTCG``: 31 Dec 1971 00:00:00.000 * Julian formats: * ``JDate``: 2441316.50000000 * ``JDTDB``: 2441316.50048824 * ``JED`` (Ephemeris date): 2441316.50048824 * ``LCLJ``: 364/71 20:00:00.000 * ``ModJDate``: 41316.00000000 * ``TAIJ``: 365/71 00:00:10.000 * ``UTCJ``: 365/71 00:00:00.000 * ``UTCJFOUR``: 365/1971 00:00:00.000 * ISO8601 UTC formats: * ``ISO-YD``: 1971-365T00:00:00.000 * ``ISO-YMD``: 1971-12-31T00:00:00.000 * Other formats: * ``EarthEpTU`` (Earth Canonical Time): 0.000 * ``GMT`` (GMT System): 365/00000 1971 * ``GPS`` (GPS Time): -0418:172809.000 * ``GPSZ`` (GPS Z Count): -168652806.000 * ``MisElap`` (Mission Elapsed): 0/00:00:00.000 * ``SunEpTU`` (Sun Canonical Time): 0.000 :Returns: :class:`python:str` Format string used to format values. .. !! processed by numpydoc !! Method detail ------------- .. py:method:: string_to_integer(string: str) -> numpy.int64 Convert a formatted string to an integer. The string must be in the correct format for the style being used. :Parameters: **string: str** Formatted string. :Returns: :obj:`int64` Value of the string. .. !! processed by numpydoc !! .. py:method:: string_to_real(string: str) -> numpy.float64 Convert a formatted string to a real value. The string must be in the correct format for the style being used. :Parameters: **string: str** Formatted string. :Returns: :obj:`float64` Value of the string. .. !! processed by numpydoc !! .. py:method:: integer_to_string(integer: numpy.int64) -> str Convert an integer to a formatted string. :Parameters: **integer: int64** Value. :Returns: :class:`python:str` Value formatted as a string. .. !! processed by numpydoc !! .. py:method:: real_to_string(real: numpy.float64) -> str Convert a real value to a formatted string. :Parameters: **real: float64** Value. :Returns: :class:`python:str` Value formatted as a string. .. !! processed by numpydoc !! .. py:method:: string_to_string(string: str) -> str Convert an unformatted string to a formatted string. :Parameters: **string: str** Unformatted string. :Returns: :class:`python:str` Formatted string. .. !! processed by numpydoc !! .. py:method:: integer_to_editable_string(integer: numpy.int64) -> str Convert an integer to an editable formatted string representation. The formatted string representation can be edited with full precision. :Parameters: **integer: int64** Value. :Returns: :class:`python:str` Value formatted as an editable string. .. !! processed by numpydoc !! .. py:method:: real_to_editable_string(real: numpy.float64) -> str Convert a real value to an editable formatted string representation. The formatted string representation can be edited with full precision. :Parameters: **real: float64** Value. :Returns: :class:`python:str` Value formatted as an editable string. .. !! processed by numpydoc !!