Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy broadcasting rules could do with simplification #140

Open
corinnebosley opened this issue Jul 12, 2018 · 2 comments
Open

numpy broadcasting rules could do with simplification #140

corinnebosley opened this issue Jul 12, 2018 · 2 comments

Comments

@corinnebosley
Copy link
Contributor

The numpy course Broadcasting section can be difficult to understand due to confusing technical language. The concept itself is quite straightforward, but there are several layers of complexity in the sentences which describe the rules, and they do not correlate to the graphics although they seem like they should, so the images actually just become confusing.

I think that this section would be easier to understand if the images matched the rules and allowed the user to understand all the loaded phrases (like 'the shape of the array with fewer dimensions ... padded ... leading (left) side'; this would be easier to unpack if you maybe showed the shape of the dimensions in a code cell, and then what it means to 'pad' it to match the shape of the other array).

@kaedonkers
Copy link
Contributor

I agree that the having broadcasting rules in the course confuses things, and I would go as far as to say we simply remove them altogether. They are technical detail gleaned from the numpy documentation and are unncessesary to understanding the concept. The diagrams along with a good explanation of the problem broadcasting addresses is good enough IMO.

@pp-mo
Copy link
Contributor

pp-mo commented Nov 30, 2018

remove them altogether ... are unnecessary to understanding the concept

Interesting. Some thoughts ...

The rules are quirky + complicated, but understanding them can be important.
My initial reaction was that it is important to get across the whole gory truth + not pretend that it's all quite obvious + straightforward, when in practice it absolutely is not !!!
However, after some soul-searching, I can support the idea that we can summarise without trying to explain it all :

  1. the basic idea is simple + useful (examples)
  2. it doesn't do everything you'd like, so in many cases you need to take control (more examples : use 'reshape' or 'newaxis' to get it to do the right thing)
  3. there is a long + complicated set of exact rules (see external reference)

Interestingly, I note that numpy docs already has such a "longer + less formal" account in the User Guide : https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html

I'm not sure I like it that much, but I have to admit that it's examples do introduce almost exactly the same ideas, in the same order, as the list I wrote out for myself !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants