RealValue
#
- class ansys.tools.variableinterop.scalar_values.RealValue#
Bases:
numpy.float64
,ansys.tools.variableinterop.variable_value.IVariableValue
Stores a value as a
RealValue
variable type.In Python, the
RealValue
type is implemented by extending NumPy’s float64 type. This means that they decay naturally intonumpy.float64
objects when using NumPy’s arithmetic operators. It also means that they inherit many of the NumPy behaviors, which may be slightly different from the behaviors specified in the variable interop standards. For example, when converting from real to integer, the value is floored instead of rounded. If you want the variable interop standard conversions, use theto_int_value()
method to get anIntegerValue
type with variable interop standard rounding (away from zero). TheIntegerValue
type decomposes naturally tonumpy.int64
objects.
Overview#
Invoke the visitor pattern of this object using the passed-in visitor |
|
Convert the value to an API string. |
|
Convert this |
|
Convert this |
|
Convert the value to a formatted string. |
Variable type of the object. |
Convert an API string back into a |
Import detail#
from ansys.tools.variableinterop.scalar_values import RealValue
Property detail#
- property RealValue.variable_type: ansys.tools.variableinterop.variable_type.VariableType#
Variable type of the object.
- Returns:
VariableType
Variable type of the object.
Method detail#
- RealValue.accept(visitor: ansys.tools.variableinterop.ivariable_visitor.IVariableValueVisitor[ansys.tools.variableinterop.ivariable_visitor.T]) ansys.tools.variableinterop.ivariable_visitor.T #
Invoke the visitor pattern of this object using the passed-in visitor implementation.
- Parameters:
- visitor
IVariableValueVisitor
Visitor object to call.
- visitor
- Returns:
T
Results of the visitor invocation.
- RealValue.to_api_string(context: ansys.tools.variableinterop.isave_context.ISaveContext | None = None) str #
Convert the value to an API string.
- Returns:
str
String appropriate for use in files and APIs.
- static RealValue.from_api_string(value: str) RealValue #
Convert an API string back into a
RealValue
type.- Parameters:
- value
str
String to convert.
- value
- RealValue.to_int_value() IntegerValue #
Convert this
RealValue
type to anIntegerValue
type.The conversion is performed according to the type interoperability specifications. The value is rounded to the nearest integer, where values with a 5 in the tenths place are always rounded away from zero. (Note that this is different from the default Python rounding behavior.)
- Returns:
IntegerValue
IntegerValue
type that is the result of rounding this value to the nearest integer. (Values with a 5 in the tenths place are rounded away from zero.)
- RealValue.to_boolean_value() BooleanValue #
Convert this
RealValue``type to a ``BooleanValue
type.The conversion is performed according to the type interoperability specifications. Any value other than exactly 0 is considered to be
True
.- Returns:
BooleanValue
BooleanValue
type that is the result of converting theRealValue
type.