heads up: gufuncs on empty arrays and NpyIter removal of empty axis

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

heads up: gufuncs on empty arrays and NpyIter removal of empty axis

Sebastian Berg
Hi all,

just a small heads up for gufunc hackers and low level iterator users.
We will probably very soon put in a commit into master that will allow
the removal of empty axis from NpyIter/nditer, effectively removing the
error:

"ValueError: cannot remove a zero-sized axis from an iterator"

and allowing:

```
arr = np.zeros((100, 0))
it = np.nditer((arr,),
               flags=["zerosize_ok", "multi_index"])
it.remove_axis(1)
```

As a follow up step, we also allow that gufuncs may be called with
empty inner loop sizes. In some cases that may mean that your gufuncs
may need special handling for lets say:

```
arr = np.zeros((100, 0))  # note the 0 dimension.
my_gufunc(arr)
```

If this creates problems for you, please tell, so that we can slow down
or undo the change. As an example, we have a matrix_multiply gufunc for
testing purpose, which did not zero out the output for the case of
`matrix_multiply(np.ones((10, 0)), np.ones((0, 10)))`. So this could
turn code that errored out for weird reasons into wrong results in rare
cases.

- Sebastian
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

signature.asc (817 bytes) Download Attachment
Loading...