Is there a test suite for Numpy's data-type API?

14 views Asked by At

I'm adding a custom data-type to Numpy, using the Data Type API, and most of the tests seem to be generic. Is there some test suite that can test the correct functionality within an array of a given data-type? i.e. that getter/setter work as expected, that element-wise operation on ndarrays of said data-type behave the same as doing the same operation on single elements (outside of Numpy), etc. That sounds trivial, but in fact this functionality depends on some boilerplate code that has to be adjusted for every custom data-type.

I've added some tests, i.e. the one below, but I'm hoping there's a test suite that would cover all of Numpy C-API functionality, since it seems generic and not related to the internals of the custom data-type.

def test_np_array_slice_bcast():
    a_arr_orig = np.asarray(range(10), dtype=MyCustomType)
    a_arr_slice = np.copy(a_arr_orig)
    a_arr_slice[::2] = MyCustomType(0)

    for x, y in zip(a_arr_orig[1::2], a_arr_slice[1::2]):
        assert x == y
    for x, y in zip(a_arr_orig[0::2], a_arr_slice[0::2]):
        assert y == MyCustomType(0)
0

There are 0 answers