Merge pull request #250 from amin-sehati/master

Remove an incorrect solution (fancy indexing) from Numpy exercise No16
This commit is contained in:
Nicolas P. Rougier
2026-02-09 18:44:25 +01:00
committed by GitHub
3 changed files with 1 additions and 11 deletions

View File

@@ -130,11 +130,6 @@ print(Z)
Z = np.ones((5,5))
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
print(Z)
# Using fancy indexing
Z[:, [0, -1]] = 0
Z[[0, -1], :] = 0
print(Z)
```
#### 17. What is the result of the following expression? (★☆☆)
```python

View File

@@ -130,11 +130,6 @@ print(Z)
Z = np.ones((5,5))
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
print(Z)
# Using fancy indexing
Z[:, [0, -1]] = 0
Z[[0, -1], :] = 0
print(Z)
```
#### 17. What is the result of the following expression? (★☆☆)
```python

View File

@@ -165,7 +165,7 @@ Z = np.ones((5,5))
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
print(Z)
# Using fancy indexing
# Not a solution to this problem but good to know: using fancy indexing for in-place edit
Z[:, [0, -1]] = 0
Z[[0, -1], :] = 0
print(Z)