NPY_INFINITY is a (C) double. I suspect the problem here is that the `ndarray.fill` method expects a python object rather than a C number, i.e., you should use np.inf instead. The `np.PyArray_FillWithScalar` function, OTOH, can handle a C type.

I think you should just try replacing `NPY_INFINITY` with `np.inf`.