[Numpy-discussion] A little about XND

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Mon Jun 18 12:34:03 EDT 2018


Hi Stefan,

That looks quite nice and expressive. In the context of a discussion we
have been having about describing `matmul/@` and possibly broadcastable
dimensions, I think from your description it sounds like one would describe
`@` with multiple functions (the multiple dispatch we have been (are?)
considering as well):


"... * N * M * T, ... * M * P * T -> ... * N * P * T"
"M * T, ... * M * P * T -> ... P * T"
"... * N * M * T, M * T -> ... * N * T"
"M * T, M * T -> T"

Is there a way to describe broadcasting?  The sample case we've come up
with is a function that calculates a weighted mean. This might take
(values, sigmas) and return (mean, sigma_mean), which would imply a
signature like:

"... N * T, ... N * T -> ... * T, ... * T"

But would your signature allow indicating that one could pass in a single
sigma? I.e., broadcast the second 1 to N if needed?

I realize that this is no longer about describing precisely what the
function doing the calculation expects, but rather what an upper level is
allowed to do before calling the function (i.e., take a dimension of 1 and
broadcast it).

All the best,

Marten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180618/b9583b6a/attachment.html>


More information about the NumPy-Discussion mailing list