[Numpy-discussion] Changes to generalized ufunc core dimension checking
Charles R Harris
charlesr.harris at gmail.com
Wed Mar 16 16:07:38 EDT 2016
On Wed, Mar 16, 2016 at 1:48 PM, Travis Oliphant <travis at continuum.io>
> On Wed, Mar 16, 2016 at 12:55 PM, Nathaniel Smith <njs at pobox.com> wrote:
>> Hi Travis,
>> On Mar 16, 2016 9:52 AM, "Travis Oliphant" <travis at continuum.io> wrote:
>> > Hi everyone,
>> > Can you help me understand why the stricter changes to generalized
>> ufunc argument checking no now longer allows scalars to be interpreted as
>> 1-d arrays in the core-dimensions?
>> > Is there a way to specify in the core-signature that scalars should be
>> allowed and interpreted in those cases as an array with all the elements
>> the same? This seems like an important feature.
>> Can you share some example of when this is useful?
> Being able to implicitly broadcast scalars to arrays is the core-function
> of broadcasting. This is still very useful when you have a core-kernel
> an want to pass in a scalar for many of the arguments. It seems that at
> least in that case, automatic broadcasting should be allowed --- as it
> seems clear what is meant.
> While you can use the broadcast* features to get the same effect with the
> current code-base, this is not intuitive to a user who is used to having
> scalars interpreted as arrays in other NumPy operations.
The `@` operator doesn't allow that.
> It used to automatically happen and a few people depended on it in several
> companies and so the 1.10 release broke their code.
> I can appreciate that in the general case, allowing arbitrary broadcasting
> on the internal core dimensions can create confusion. But, scalar
> broadcasting still makes sense.
Mixing array multiplications with scalar broadcasting is looking for
trouble. Array multiplication needs strict dimensions and having stacked
arrays and vectors was one of the prime objectives of gufuncs. Perhaps what
we need is a more precise notation for broadcasting, maybe `*` or some such
addition to the signaturs to indicate that scalar broadcasting is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion