{"record":{"id":"6cdfff2baaa739bd","repo":"Genesis-Embodied-AI/genesis-world","slug":"expected-an-instance-of-a-class-that-inherits-from","errorCode":null,"errorMessage":"Expected an instance of a class that inherits from TetGenMixin, but got an instance of {type(morph).name}.","messagePattern":"Expected an instance of a class that inherits from TetGenMixin, but got an instance of (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"genesis/utils/mesh.py","lineNumber":1359,"sourceCode":"            uv_coords = np.vstack([uv_coords, uv_coords])\n\n        vmesh.visual = trimesh.visual.TextureVisuals(\n            uv=uv_coords,\n            material=trimesh.visual.material.SimpleMaterial(\n                image=Image.open(os.path.join(get_assets_dir(), texture_path)),\n            ),\n        )\n    else:\n        vmesh.visual = trimesh.visual.ColorVisuals(\n            vertex_colors=np.tile(np.asarray(color, dtype=np.float32), (len(vmesh.vertices), 1))\n        )\n\n    return vmesh, mesh\n\n\ndef generate_tetgen_config_from_morph(morph):\n    if not isinstance(morph, gs.options.morphs.TetGenMixin):\n        raise TypeError(\n            f\"Expected an instance of a class that inherits from TetGenMixin, but got an instance of {type(morph).name}.\"\n        )\n    return dict(\n        order=morph.order,\n        mindihedral=morph.mindihedral,\n        minratio=morph.minratio,\n        nobisect=morph.nobisect,\n        quality=morph.quality,\n        maxvolume=morph.maxvolume,\n        verbose=morph.verbose,\n    )\n\n\ndef make_tetgen_switches(cfg):\n    \"\"\"Build a TetGen switches string from a config dict.\"\"\"\n    flags = [\"p\"]\n\n    if cfg.get(\"quality\", True):","sourceCodeStart":1341,"sourceCodeEnd":1377,"githubUrl":"https://github.com/Genesis-Embodied-AI/genesis-world/blob/56e4aa5d82bdb83f2e532e4cc364cb69527acb06/genesis/utils/mesh.py#L1341-L1377","documentation":"generate_tetgen_config_from_morph builds the TetGen keyword configuration dict from a morph's tetrahedralization options, and it requires the morph to be a class mixing in gs.options.morphs.TetGenMixin (which provides order, mindihedral, minratio, etc.). Passing any other morph type means those fields do not exist, so a TypeError is raised immediately with the offending class name. Callers tet_cfg and sample rely on this contract.","triggerScenarios":"Passing a non-tetrahedralizable morph (e.g. gs.morphs.Mesh, gs.morphs.Box, gs.morphs.URDF) to generate_tetgen_config_from_morph (or to an API like tet_cfg/sample that forwards the morph). Using a custom morph class that does not inherit from TetGenMixin.","commonSituations":"Building a tetrahedral FEM/volumetric entity but passing the wrong morph type; copy-pasting an example that used TetGenMixin-based morphs (e.g. a morph with tetrahedralize options) while the actual morph is a plain Mesh; writing a custom morph and forgetting the mixin.","solutions":["Use a morph class that inherits TetGenMixin (the tetrahedralizable morphs in gs.options.morphs) so order/mindihedral/minratio fields exist.","If writing a custom morph, subclass or mix in gs.options.morphs.TetGenMixin and define its fields.","Check what you actually passed: print(type(morph)) at the call site and compare with the morphs exposed by gs.options.morphs."],"exampleFix":"# before\ncfg = generate_tetgen_config_from_morph(gs.morphs.Mesh(file='part.stl'))\n# after\ncfg = generate_tetgen_config_from_morph(gs.morphs.Tet(file='part.stl'))  # TetGenMixin-based morph","handlingStrategy":"type-guard","validationCode":"from genesis.options import morphs\nassert isinstance(morph, morphs.TetGenMixin), f'{type(morph).__name__} cannot be tetrahedralized'","typeGuard":"def is_tetgen_morph(morph) -> bool:\n    return isinstance(morph, __import__('genesis').options.morphs.TetGenMixin)","tryCatchPattern":"try:\n    cfg = generate_tetgen_config_from_morph(morph)\nexcept TypeError as e:\n    raise ValueError(f'Wrong morph for tetrahedralization: {e}') from e","preventionTips":["Pick morph classes from gs.options.morphs that match the downstream solver capability.","Mix TetGenMixin into custom morphs that must support tetrahedralization."],"tags":["genesis","tetgen","type-validation","morphs","options"],"backgroundTag":"wrong-argument-type","analyzedSha":"56e4aa5d82bdb83f2e532e4cc364cb69527acb06","analyzedAt":"2026-08-28T15:15:07.922Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}