Skip to content

Support indexedarray fields in struct #1327

Closed

Description

@FabienPean-Virtonomy

wp.indexedarray cannot currently be used as a field in wp.struct (assignment/device transfer/NumPy structured values) while it can be passed as an argument to a wp.kernel. There is no apparent reason not to support this possibility as all the blocks are already in place.

Minimal example for currently erroneous behavior:

import warp as wp

@wp.struct
class Foo:
    arr: wp.indexedarray(dtype=wp.float32)

Result:

Traceback (most recent call last):
  File "examples/tmp.py", line 4, in <module>
    @wp.struct
     ^^^^^^^^^
  File ".pixi/envs/default/lib/python3.12/site-packages/warp/_src/context.py", line 1451, in struct
    return wrapper(c)
           ^^^^^^^^^^
  File ".pixi/envs/default/lib/python3.12/site-packages/warp/_src/context.py", line 1443, in wrapper
    s = warp._src.codegen.Struct(key=warp._src.codegen.make_full_qualified_name(c), cls=c, module=m)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".pixi/envs/default/lib/python3.12/site-packages/warp/_src/codegen.py", line 522, in __init__
    elif issubclass(var.type, ctypes.Array):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

Expected:
Allow wp.indexedarray fields in structs with the same behavior as wp.array:

  • assign indexedarray (or None) to struct fields
  • StructInstance.to(device) moves indexedarray members
  • works in kernels, nested structs, and struct arrays
  • Struct.numpy_dtype() / StructInstance.numpy_value() work

Activity

  1. added this to the 1.13.0 milestone on Mar 30, 2026
  2. shi-eric commented on Apr 16, 2026

    @shi-eric
    Contributor

    This was merged in 537ae37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions