[Numpy-discussion] Allowing broadcasting of code dimensions in generalized ufuncs

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Wed May 30 20:21:50 EDT 2018


Hi Stephan, Matt,

My `n|1` was indeed meant to be read as `n or 1`, but with the
(implicit) understanding that any array can have as many ones
pre-pended as needed.

The signature `(n?),(n?)->()` is now set aside for flexible
dimensions: this would allow the constant, but not the trailing shape
of 1 (at least as we currently have implemented it). I do think that
is more consistent with the visual suggestion, that the think may be
absent. It also has implications for output: `(m?,n),(n,p?)->(m?,p?)`
is meant to indicate that if a dimension is absent, it should be
absent in the output as well. In contrast, for broadcasting, I'd
envisage `(n|1),(n|1)->(n)` to indicate that the output dimension will
always be present and be of length n.

I'm not sure I'm sold on `n^` - I don't think it gives an immediate
hint of what it would do...

All the best,

Marten


More information about the NumPy-Discussion mailing list