ArrayToFromStringUtil#
- class ArrayToFromStringUtil#
Provides utility methods for converting CommonValueArray
objects to and from
Overview#
Convert an array value to a string representation of it. |
|
Convert a string into a |
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:
- value
NDArray
Array value to convert.
- stringify_action
Callable
Action to use to convert each individual value in the array.
- value
- 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:
- value
str
String value to parse.
- create_action
Callable
[[Any
],CommonArrayValue
] Action that takes either a shape or a list of initial values and creates a new array of the correct type.
- valueify_action
Callable
[[str
],IVariableValue
] Action used to parse each individual value to the correct type.
- value
- Returns:
CommonArrayValue
A new array object with the parsed values.