CommonVariableMetadata#

class CommonVariableMetadata#

Bases: abc.ABC

Provides metadata common to all variables.

Overview#

accept

Invoke the visitor pattern of this object using the passed-in visitor

equals

Determine if the object is equal to the metadata.

clone

Get a deep copy of the metadata.

get_default_value

Get the default value that should be used for a variable described by this

runtime_convert

Convert the value of the variable to the appropriate type for this metadata.

description

Description of the variable.

custom_metadata

Custom metadata stored in a dictionary.

variable_type

Variable type of the object.

__eq__

Determine if the object is equal to the metadata.

Import detail#

from ansys.tools.variableinterop.common_variable_metadata import CommonVariableMetadata

Property detail#

property CommonVariableMetadata.description: str#

Description of the variable.

property CommonVariableMetadata.custom_metadata: Dict[str, ansys.tools.variableinterop.variable_value.IVariableValue]#

Custom metadata stored in a dictionary.

property CommonVariableMetadata.variable_type: VariableType#
Abstractmethod:

Variable type of the object.

Returns:
VariableType

Variable type of the object.

Method detail#

CommonVariableMetadata.__eq__(other)#

Determine if the object is equal to the metadata.

CommonVariableMetadata.equals(other: Any) bool#

Determine if the object is equal to the metadata.

Parameters:
otherAny

Other object to compare this object to.

Returns:
bool

True if the metadata objects are equal, False otherwise.

CommonVariableMetadata.clone() CommonVariableMetadata#

Get a deep copy of the metadata.

abstract CommonVariableMetadata.accept(visitor: ansys.tools.variableinterop.ivariablemetadata_visitor.IVariableMetadataVisitor[ansys.tools.variableinterop.ivariablemetadata_visitor.T]) ansys.tools.variableinterop.ivariablemetadata_visitor.T#

Invoke the visitor pattern of this object using the passed-in visitor implementation.

Parameters:
visitorIVariableMetadataVisitor[T]

Visitor object to call.

Returns:
T

Results of the visitor invocation.

CommonVariableMetadata.get_default_value() ansys.tools.variableinterop.variable_value.IVariableValue#

Get the default value that should be used for a variable described by this metadata.

The metadata may have set the lower bound, upper bound, or enumerated values, which restricts what values are valid. This method selects a valid default value.

  • If the type’s default value (such as 0 or an empty string) is a valid value for the metadata, use it.

  • If the metadata has enumerated values, select the first enumerated value that is valid per the other restrictions.

  • If the metadata has a lower bound and it is valid, use it.

  • If metadata does not have a lower bound but does have an upper bound, use the upper bound.

  • If no value is valid, use the type’s default value.

CommonVariableMetadata.runtime_convert(source: ansys.tools.variableinterop.variable_value.IVariableValue) ansys.tools.variableinterop.variable_value.IVariableValue#

Convert the value of the variable to the appropriate type for this metadata.

Parameters:
sourceIVariableValue

Value to convert

Returns:
IVariableValue

Value converted to the appropriate type.