[Numpy-discussion] ndarray.T2 for 2D transpose
chris.barker at noaa.gov
Thu Apr 7 14:17:34 EDT 2016
On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen <
insertinterestingnamehere at gmail.com> wrote:
> Here's another example that I've seen catch people now and again.
> A = np.random.rand(100, 100)
> b = np.random.rand(10)
> A * b.T
typo? that was supposed to be
b = np.random.rand(100). yes?
This is exactly what someone else referred to as the expectations of
someone that comes from MATLAB, and doesn't yet "get" that 1D arrays are 1D
All of this is EXACTLY the motivation for the matric class -- which never
took off, and was never complete (it needed a row and column vector
implementation, if you ask me. But Ithikn the reason it didn't take off is
that it really isn't that useful, but is different enough from regular
arrays to be a greater source of confusion. And it was decided that all
people REALLY wanted was an obviou sway to get matric multiply, which we
now have with @.
So this discussion brings up that we also need an easy an obvious way to
make a column vector --
which would be a synonym for np.reshape(arr, (-1,1))
would that make anyone happy?
NOTE: having transposing a 1D array raise an exception would help remove a
lot of the confusion, but it may be too late for that....
In this case the user pretty clearly meant to be broadcasting along the
> rows of A
> rather than along the columns, but the code fails silently.
hence the exception idea....
maybe a warning?
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion