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

Added challenge to 01-numpy.md regarding slicing a vector vs an array #211

Merged
merged 2 commits into from
Jun 21, 2016
Merged

Conversation

metavee
Copy link
Contributor

@metavee metavee commented Jan 21, 2016

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.

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.

> ## Converting between an array and a vector {.challenge}
>
> In some cases in NumPy, an vector of size N behaves differently than an Nx1 array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this challenge really explains how it might behave differently, or why that might even be a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@metavee
Copy link
Contributor Author

metavee commented Jun 17, 2016

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.

@valentina-s
Copy link
Contributor

That looks good! Thank you for the contribution!

@valentina-s valentina-s merged commit 1a25bbf into swcarpentry:gh-pages Jun 21, 2016
maxim-belkin pushed a commit to maxim-belkin/python-novice-inflammation that referenced this pull request Mar 28, 2018
zkamvar pushed a commit that referenced this pull request Apr 21, 2023
Added challenge to 01-numpy.md regarding slicing a vector vs an array
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

Successfully merging this pull request may close these issues.

None yet

3 participants