Skip to content

[BUG] Can’t Initialize Array From Incomplete Cuda Array Interface Description #523

@christophercrouzet

Description

@christophercrouzet

Bug Description

If an array points_array defines a __cuda_array_interface__ but has no value set for the strides field, then calling wp.array(points_array, dtype=wp.vec3, device="cuda") fails since wp.array._init_from_data() tries to subscript the non-existing strides.

Repro

import numpy as np
import warp as wp

class MyArrayInterface:
    def __init__(self, data):
        self.data = np.array(data)
        self.__cuda_array_interface__ = self.data.__array_interface__
        self.__len__ = self.data.__len__

array = MyArrayInterface((1, 2, 3))
wp_array = wp.array(array, dtype=wp.vec3, device="cuda")
assert wp_array.ptr != 0

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions