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

2018-05-30 Thread Marten van Kerkwijk
Hi All, Following on a PR combining the ability to provide fixed and flexible dimensions [1] (useful for, e.g., 3-vector input with a signature like `(3),(3)->(3)`, and for `matmul`, resp.; based on earlier PRs by Jaime [2] and Matt (Picus) [3]), I've now made a PR with a further enhancement, whic

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

2018-05-30 Thread Stephan Hoyer
On Wed, May 30, 2018 at 11:15 AM Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote: > My PR provides the ability to indicate in the signature that a core > dimension can be broadcast, by using a suffix of "|1". Thus, the > signature of `all_equal` would become: > > ``` > (n|1),(n|1)->() > ```

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

2018-05-30 Thread Matthew Harrigan
"short-cut to automatically return False if m != n", that seems like a silent bug AFAICT there are 3 possibilities: 1) current behavior 2) a scalar or size 1 array may be substituted, ie a constant 3) a scalar or array with shape[-1] == 1 may be substituted and broadcasted I am fond of using "n^"

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

2018-05-30 Thread Marten van Kerkwijk
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

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

2018-05-30 Thread Nathaniel Smith
On Wed, May 30, 2018 at 11:14 AM, Marten van Kerkwijk wrote: > Hi All, > > Following on a PR combining the ability to provide fixed and flexible > dimensions [1] (useful for, e.g., 3-vector input with a signature like > `(3),(3)->(3)`, and for `matmul`, resp.; based on earlier PRs by Jaime > [2] a