-
Notifications
You must be signed in to change notification settings - Fork 311
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
Broadcast Illustration #265
Comments
draft. Doesn't look good in github, fine in vim, fine in rustdoc's fonts. array![0, 1, 2] + array![1]
shape [3] + shape [1] = shape [3]
┌───┬───┬───┐ ┌───┐┄┄┄┬┄┄┄╮ ┌───┬───┬───┐
│ 0 │ 1 │ 2 │ + │ 1 │ 1 ┊ 1 ┊ = │ 1 │ 2 │ 3 │
└───┴───┴───┘ └───┘┄┄┄┴┄┄┄╯ └───┴───┴───┘
array![[1, 1, 1],
[1, 1, 1],
[1, 1, 1]] + array![0, 1, 2]
shape [3, 3] + shape [3] = shape [3, 3]
┌───┬───┬───┐ ┌───┬───┬───┐ ┌───┬───┬───┐
│ 1 │ 1 │ 1 │ │ 0 │ 1 │ 2 │ │ 1 │ 2 │ 3 │
├───┼───┼───┤ └───┴───┴───┘ ├───┼───┼───┤
│ 1 │ 1 │ 1 │ + ┊ 0 ┊ 1 ┊ 2 ┊ = │ 1 │ 2 │ 3 │
├───┼───┼───┤ ├┄┄┄ ┄┄┄ ┄┄┄┤ ├───┼───┼───┤
│ 1 │ 1 │ 1 │ ┊ 0 ┊ 1 ┊ 2 ┊ │ 1 │ 2 │ 3 │
└───┴───┴───┘ ╰┄┄┄┴┄┄┄┴┄┄┄╯ └───┴───┴───┘
array![[0],
[1],
[2]] + array![[0, 1, 2]]
shape [3, 1] + shape [1, 3] = shape [3, 3]
┌───┐┄┄┄ ┄┄┄╮ ┌───┬───┬───┐ ┌───┬───┬───┐
│ 0 │ 0 ┊ 0 ┊ │ 0 │ 1 │ 2 │ │ 0 │ 1 │ 2 │
├───┤┄┄┄ ┄┄┄ └───┴───┴───┘ ├───┼───┼───┤
│ 1 │ 1 ┊ 1 ┊ + ┊ 0 ┊ 1 ┊ 2 ┊ = │ 1 │ 2 │ 3 │
├───┤┄┄┄ ┄┄┄ ┄┄┄ ┄┄┄ ┄┄┄ ├───┼───┼───┤
│ 2 │ 2 ┊ 2 ┊ ┊ 0 ┊ 1 ┊ 2 ┊ │ 1 │ 3 │ 4 │
└───┘┄┄┄ ┄┄┄╯ ╰┄┄┄ ┄┄┄ ┄┄┄╯ └───┴───┴───┘ |
I'm a long time numpy user and am I'm having a hard time understanding how broadcasting semantics work here. In fact, if I try your third example from the previous comment I get an error:
Is this expected? |
yes, ndarray does not implement the third case. |
Ok, thanks for the answer. Are there plans to implement the third case, or is this something that will not become a feature of this library? |
As you know arrays in ndarray have dimensionality in the type. If we add As it is right now, the I haven't attempted implementing it; I'm in general not so keen on more generic noise than absolutely necessary. Every bit makes the library hard to understand, and many apparently already think it is hard to get into. |
OK that makes sense -- thanks for the clarification. |
We never ended up adding broadcasting illustrations for #565 so I guess we're still waiting for that. |
This one is really good, ndarray should adopt this (just need to change the code for each illu)
http://www.astroml.org/book_figures/appendix/fig_broadcast_visual.html
The text was updated successfully, but these errors were encountered: