Format#
- class Format(fmt: str, engine: ansys.modelcenter.workflow.grpc_modelcenter.engine.Engine)#
Bases: 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.
Overview#
Convert a formatted string to an integer. |
|
Convert a formatted string to a real value. |
|
Convert an integer to a formatted string. |
|
Convert a real value to a formatted string. |
|
Convert an unformatted string to a formatted string. |
|
Convert an integer to an editable formatted string representation. |
|
Convert a real value to an editable formatted string representation. |
Style to use for formatting. |
Import detail#
from ansys.modelcenter.workflow.grpc_modelcenter.format import Format
Property detail#
- property Format.format: 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
: 0EpMin
: 0.00000EpHr
: 0.0000000EpDay
: 0.00000000EpYr
: 0.00000000000
Standard display formats:
DD/MM/YYY
: 31/21/1971 00:00:00.000YYDDD
: 71365.00000000YYYYDDD
: 1971365.000000YYYYMMDD
: 19711231.00000000YYYY/MM/DD
: 1971/12/31 00:00:00.000YYYY:MM:DD
: 1971:12:31:00:00:00.000
Gregorian formats:
GPSG
: 30 Dec 1971 23:59:51.000LCLG
: 30 Dec 1971 20:00:00.000TAIG
: 31 Dec 1971 00:00:10.000TDBG
: 31 Dec 1971 00:00:42.184TDTG
: 31 Dec 1971 00:00:42.184UTCG
: 31 Dec 1971 00:00:00.000
Julian formats:
JDate
: 2441316.50000000JDTDB
: 2441316.50048824JED
(Ephemeris date): 2441316.50048824LCLJ
: 364/71 20:00:00.000ModJDate
: 41316.00000000TAIJ
: 365/71 00:00:10.000UTCJ
: 365/71 00:00:00.000UTCJFOUR
: 365/1971 00:00:00.000
ISO8601 UTC formats:
ISO-YD
: 1971-365T00:00:00.000ISO-YMD
: 1971-12-31T00:00:00.000
Other formats:
EarthEpTU
(Earth Canonical Time): 0.000GMT
(GMT System): 365/00000 1971GPS
(GPS Time): -0418:172809.000GPSZ
(GPS Z Count): -168652806.000MisElap
(Mission Elapsed): 0/00:00:00.000SunEpTU
(Sun Canonical Time): 0.000
- Returns:
str
Format string used to format values.
Method detail#
- Format.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:
int64
Value of the string.
- Format.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:
float64
Value of the string.
- Format.integer_to_string(integer: numpy.int64) str #
Convert an integer to a formatted string.
- Parameters:
- integer: int64
Value.
- Returns:
str
Value formatted as a string.
- Format.real_to_string(real: numpy.float64) str #
Convert a real value to a formatted string.
- Parameters:
- real: float64
Value.
- Returns:
str
Value formatted as a string.
- Format.string_to_string(string: str) str #
Convert an unformatted string to a formatted string.
- Parameters:
- string: str
Unformatted string.
- Returns:
str
Formatted string.