ArrayToFromStringUtil#

class ArrayToFromStringUtil#

Provides utility methods for converting CommonValueArray objects to and from

Overview#

value_to_string

Convert an array value to a string representation of it.

string_to_value

Convert a string into a CommonValueArray object.

Import detail#

from ansys.tools.variableinterop.utils.array_to_from_string_util import ArrayToFromStringUtil

Method detail#

static ArrayToFromStringUtil.value_to_string(value: numpy.typing.NDArray, stringify_action: Callable) str#

Convert an array value to a string representation of it.

The stringify_action() method allows converting the value arbitrarily, so both API and display strings can use this method.

Parameters:
valueNDArray

Array value to convert.

stringify_actionCallable

Action to use to convert each individual value in the array.

Returns:
str

Generated string.

static ArrayToFromStringUtil.string_to_value(value: str, create_action: Callable[[Any], ansys.tools.variableinterop.variable_value.CommonArrayValue], valueify_action: Callable[[str], ansys.tools.variableinterop.variable_value.IVariableValue]) ansys.tools.variableinterop.variable_value.CommonArrayValue#

Convert a string into a CommonValueArray object.

The valueify_action() method allows converting the value arbitrarily, so both API and display strings can use this method.

Parameters:
valuestr

String value to parse.

create_actionCallable[[Any], CommonArrayValue]

Action that takes either a shape or a list of initial values and creates a new array of the correct type.

valueify_actionCallable[[str], IVariableValue]

Action used to parse each individual value to the correct type.

Returns:
CommonArrayValue

A new array object with the parsed values.