mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Fix missing f-string prefix in `msh2obj` texcoord error message

Open Nas01010101 opened this issue 6 months ago • 0 comments

Problem

In msh2obj.py, the texcoord-count validation in Msh.create spans two string literals, but only the first has an f prefix:

if vertex_texcoords.size != 2 * ntexcoord:
    raise ValueError(
        f"Invalid number of texcoords: {vertex_texcoords.size} != "
        "2*{ntexcoord}."        # <-- missing f
    )

So the message emits the literal text 2*{ntexcoord} instead of the expected count, e.g.:

Invalid number of texcoords: 2 != 2*{ntexcoord}.

rather than the intended ... != 2*5.. The sibling vertices, normals, and faces messages interpolate correctly; only this one was missed.

Fix

Add the f prefix to the continuation literal.

Tests

Adds test_texcoord_size_mismatch_error_reports_expected_count, which feeds a .msh declaring ntexcoord=5 but only 2 texcoord floats and asserts the error reports the computed count (2 != 2*5.). It fails before this change (the message contains the literal {ntexcoord}) and passes after; the rest of msh2obj_test.py remains green.

Nas01010101 avatar May 30 '26 16:05 Nas01010101