[Numpy-discussion] Consider improving numpy.outer's behavior with zero-dimensional vectors

Matthew Brett matthew.brett at gmail.com
Thu Apr 16 18:28:34 EDT 2015


Hi,

On Thu, Apr 16, 2015 at 3:19 PM, Neil Girdhar <mistersheik at gmail.com> wrote:
> Actually, looking at the docs, numpy.outer is *only* defined for 1-d
> vectors.  Should anyone who used it with multi-dimensional arrays have an
> expectation that it will keep working in the same way?
>
> On Thu, Apr 16, 2015 at 10:53 AM, Neil Girdhar <mistersheik at gmail.com>
> wrote:
>>
>> Would it be possible to deprecate np.outer's usage on non one-dimensional
>> vectors for a few versions, and then reintroduce it with definition np.outer
>> == np.multiply.outer?

I think the general idea is that

a) people often miss deprecation warnings
b) there is lots of legacy code out there, and
c) it's very bad if legacy code silently gives different answers in
newer numpy versions
d) it's not so bad if newer numpy gives an intelligible error for code
that used to work.

So, how about a slight modification of your proposal?

1) Raise deprecation warning for np.outer for non 1D arrays for a few
versions, with depraction in favor of np.multiply.outer, then
2) Raise error for np.outer on non 1D arrays

Best,

Matthew



More information about the NumPy-Discussion mailing list