newton.utils.string_to_warp#

newton.utils.string_to_warp(value, warp_dtype, default=None)[source]#

Parse a Warp value from a string. This is useful for parsing values from XML files. For example, “1.0 2.0 3.0” will be parsed as wp.vec3(1.0, 2.0, 3.0).

If fewer values are provided than expected for vector/matrix types, the remaining values will be filled from the default value if provided.

Raises:

ValueError – If the dtype is invalid.

Parameters:
  • value (str) – The string value to parse.

  • warp_dtype (Any) – The Warp dtype to parse the value as.

  • default (Any) – Optional default value to use for padding incomplete vectors/matrices.

Returns:

The parsed Warp value.

Return type:

Any