Skip to content

[BUG] RuntimeError occurs when wp.func with default arguments is called from Python #386

@eric-heiden

Description

@eric-heiden

Bug Description

wp.func-decorated functions cannot be called from a Python context if they have default arguments which are not provided by the caller.

Example:

import warp as wp

@wp.func
def allclose(a: wp.vec3, b: wp.vec3, rtol: float = 1e-5, atol: float = 1e-8):
    return (
        wp.abs(a[0] - b[0]) <= (atol + rtol * wp.abs(b[0]))
        and wp.abs(a[1] - b[1]) <= (atol + rtol * wp.abs(b[1]))
        and wp.abs(a[2] - b[2]) <= (atol + rtol * wp.abs(b[2]))
    )

allclose(wp.vec3(0.0, 0.0, 1.0), wp.vec3(0.0, 0.0, 1.0))

triggers the following error:

Exception has occurred: RuntimeError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Error calling function 'allclose', no overload found for arguments (<warp.types.vec3f object at 0x0000021BFEDBCAC0>, <warp.types.vec3f object at 0x0000021BFEDBCB40>)

System Information

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions