[Numpy-discussion] Forcing gufunc to error with size zero input
wieser.eric+numpy at gmail.com
Sat Sep 28 21:03:50 EDT 2019
Can you just raise an exception in the gufuncs inner loop? Or is there no
mechanism to do that today?
I don't think you were proposing that core dimensions should _never_ be
allowed to be 0, but if you were I disagree. I spent a fair amount of work
enabling that for linalg because it provided some convenient base cases.
We could go down the route of augmenting the gufuncs signature syntax to
support requiring non-empty dimensions, like we did for optional ones -
although IMO we should consider switching from a string minilanguage to a
structured object specification if we plan to go too much further with
On Sat, Sep 28, 2019, 17:47 Warren Weckesser <warren.weckesser at gmail.com>
> I'm experimenting with gufuncs, and I just created a simple one with
> signature '(i)->()'. Is there a way to configure the gufunc itself so
> that an empty array results in an error? Or would I have to create a
> Python wrapper around the gufunc that does the error checking?
> Currently, when passed an empty array, the ufunc loop is called with
> the core dimension associated with i set to 0. It would be nice if
> the code didn't get that far, and the ufunc machinery "knew" that this
> gufunc didn't accept a core dimension that is 0. I'd like to
> automatically get an error, something like the error produced by
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion