{"record":{"id":"b1a5416892ee2dd4","repo":"Genesis-Embodied-AI/genesis-world","slug":"position-must-have-shape-3","errorCode":null,"errorMessage":"position must have shape (3,)","messagePattern":"position must have shape \\(3,\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"genesis/engine/force_fields.py","lineNumber":168,"sourceCode":"\n    Parameters:\n    -----------\n    strength: float\n        The strength of the wind.\n    position: array_like, shape=(3,)\n        The position of the point.\n    flow: float\n        The flow of the force field.\n    falloff_pow: float\n        The power of the falloff.\n    \"\"\"\n\n    def __init__(self, strength=1.0, position=(0, 0, 0), falloff_pow=0.0, flow=1.0):\n        super().__init__()\n\n        position = np.array(position)\n        if position.shape != (3,):\n            raise ValueError(\"position must have shape (3,)\")\n\n        self._strength = strength\n        self._position = position\n        self._falloff_pow = falloff_pow\n        self._flow = flow\n\n        self._position_qd = qd.Vector(self._position, dt=gs.qd_float)\n\n    @qd.func\n    def _get_acc(self, pos, vel, t, i):\n        relative_pos = pos - self._position_qd\n        radius = relative_pos.norm(gs.EPS)\n        direction = relative_pos / radius\n        falloff = 1 / (radius + 1.0) ** self._falloff_pow\n        acc = self._strength * direction\n\n        # flow\n        acc += (acc - vel) * self._flow","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/Genesis-Embodied-AI/genesis-world/blob/56e4aa5d82bdb83f2e532e4cc364cb69527acb06/genesis/engine/force_fields.py#L150-L186","documentation":"A hybrid position/flow force field validates its position argument: np.asarray(position) must have shape exactly (3,). Any other shape raises this ValueError in __init__.","triggerScenarios":"Passing position=[0,0] or a nested/scalar value to HybridForceField(position=...); supplying a (3,1) array or a batch of positions where one is expected.","commonSituations":"Defining wind-with-falloff fields positioned at a target location and passing a 2D coordinate, or reusing an array from a geometry pipeline with an extra axis.","solutions":["Pass a flat 3-vector: position=[0, 0, 2]","Flatten arrays: np.ravel(pos) before passing","Validate config values with a shape check before scene construction"],"exampleFix":"# before\nfield = HybridForceField(strength=1.0, position=[0, 0])\n# after\nfield = HybridForceField(strength=1.0, position=[0, 0, 0])","handlingStrategy":"validation","validationCode":"position = np.ravel(position)\nassert position.shape == (3,), 'position must be a flat 3-vector'\nfield = HybridForceField(strength=1.0, position=position)\n","typeGuard":"def is_vec3(x) -> bool:\n    return np.asarray(x).shape == (3,)\n","tryCatchPattern":"try:\n    field = HybridForceField(position=position, strength=1.0)\nexcept ValueError as e:\n    raise ValueError(f'invalid position {position!r}: {e}') from e\n","preventionTips":["Coerce all spatial args with np.ravel and a shape assertion at the config boundary","Unit-test scene builders with malformed vector inputs"],"tags":["genesis","force-field","validation","shape-mismatch"],"backgroundTag":"argument-shape-validation","analyzedSha":"56e4aa5d82bdb83f2e532e4cc364cb69527acb06","analyzedAt":"2026-08-28T15:15:07.922Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}