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

Q16 fancy indexing solution does not work #167

Open
Objectivitix opened this issue Jan 4, 2022 · 1 comment
Open

Q16 fancy indexing solution does not work #167

Objectivitix opened this issue Jan 4, 2022 · 1 comment

Comments

@Objectivitix
Copy link

An example:

>>> a = np.random.randint(0, 10, (3, 3))
>>> a[:, [0, -1]] = 0
>>> a[[0, -1], :] = 0
>>> a
array([[0, 0, 0],
       [0, 5, 0],
       [0, 0, 0]])

Unless I'm understanding the question incorrectly here (but the np.pad solution is doing what I first expected), the fancy indexing solution does not work.

@rougier
Copy link
Owner

rougier commented Jan 5, 2022

The first solution extends the array (final shape is (5,5)) while the second solution does not. Maybe it's worth to add a comment saying external/internal border to distinguish between the two solutions.

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

2 participants