[Numpy-discussion] Proposed deprecations for 1.10: dot corner cases

Nathaniel Smith njs at pobox.com
Sat May 9 16:26:58 EDT 2015


Hi all,

I'd like to suggest that we go ahead and add deprecation warnings to
the following operations. This doesn't commit us to changing anything
on any particular time scale, but it gives us more options later.

1) dot(A, B) where A and B *both* have *3 or more dimensions*:
currently, this does a weird "outer product" thing, where it computes
all pairwise matrix products. We've had numerous discussions about why
this is suboptimal, and it contradicts the PEP 465 semantics for @,
which broadcast + vectorize over extra dimensions. (If you have a
vectorized version, then the outer product one is easy to derive; if
you have only the outer product version .) While dot() is widely used
in general, this particular varient is very, very rarely used. I
propose we issue a FutureWarning here, so as to lay the groundwork for
someday eventually making dot() and @ the same.

2) dot(A, B) where one of the argument is a scalar: currently, this
does scalar multiplication. There is no logically consistent
motivation for this, it violates TOOWTDI, and again it is inconsistent
with the PEP semantics for @ (which are that this case should be an
error). (NB for those still using np.matrix: scalar * np.matrix will
still be supported regardless; this would only affect expressions
where you actually call the dot() function.) I propose to make this a
DeprecationWarning.

-- 
Nathaniel J. Smith -- http://vorpus.org



More information about the NumPy-Discussion mailing list