Added challenge to 01-numpy.md regarding slicing a vector vs an array#211
Added challenge to 01-numpy.md regarding slicing a vector vs an array#211valentina-s merged 2 commits intoswcarpentry:gh-pagesfrom metavee:gh-pages
Conversation
Illustrates one of the differences between NumPy and MATLAB/intuition. Depending on the way you slice something, you may get back a 1D (N,) or 2D (Nx1) array, which can cause weird errors if you aren't expecting it.
01-numpy.md
Outdated
There was a problem hiding this comment.
I don't think this challenge really explains how it might behave differently, or why that might even be a problem?
There was a problem hiding this comment.
Fair point. In my experience, it generally results in strange-looking broadcasting errors.
Perhaps I could reformat this as a small code fragment that results in such an error, and the challenge would be to fix the error. Do you think that would work better?
|
I updated the challenge to try and guide the participants to the error in an example. I'm not totally satisfied with how it turned out, but I found it quite challenging to come up with a clear and simple example. It would be great to get feedback on whether or not this is salvageable. |
|
That looks good! Thank you for the contribution! |
Added challenge to 01-numpy.md regarding slicing a vector vs an array
Illustrates one of the differences between NumPy and MATLAB/intuition. Depending on the way you slice something, you may get back a 1D (N,) or 2D (Nx1) array, which can cause weird errors if you aren't expecting it.