[Numpy-discussion] ndarray.T2 for 2D transpose
insertinterestingnamehere at gmail.com
Thu Apr 7 13:00:33 EDT 2016
On Wed, Apr 6, 2016 at 3:21 PM Nathaniel Smith <njs at pobox.com> wrote:
> Can you elaborate on what you're doing that you find verbose and
> confusing, maybe paste an example? I've never had any trouble like
> this doing linear algebra with @ or dot (which have similar semantics
> for 1d arrays), which is probably just because I've had different use
> cases, but it's much easier to talk about these things with a concrete
> example in front of us to put everyone on the same page.
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
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. When an issue
gets mixed into a larger series of broadcasting operations, the error
difficult to find. This error isn't necessarily unique to beginners either.
common typo that catches intermediate users who know about broadcasting
semantics but weren't keeping close enough track of the dimensionality of
different intermediate expressions in their code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion