Compare commits

...

8 Commits

Author SHA1 Message Date
rougier
e865a958ed solutions update from a4bf63e 2026-02-09 17:44:51 +00:00
Nicolas P. Rougier
a4bf63e6bc Merge pull request #250 from amin-sehati/master
Remove an incorrect solution (fancy indexing) from Numpy exercise No16
2026-02-09 18:44:25 +01:00
Amin Sehati
d421b9750c Added a fancy indexing solution for 16 2026-02-09 08:54:37 -05:00
Amin Sehati
4a3372ed11 Remove an incorrect solution (fancy indexing) from Numpy exercise No. 16 in the solutions files. 2026-02-08 16:58:53 -05:00
rougier
6447594ad6 solutions update from 9642cab 2025-11-06 16:13:10 +00:00
Nicolas P. Rougier
9642cab77c Merge pull request #249 from LegendTejas/fix-issue-247-ktx
Fix #247 : replaced deprecated np.int and corrected formatting in exercises100.ktx
2025-11-06 17:12:45 +01:00
Tejas Tp
4ccd5c0689 Format np.genfromtxt parameters for consistency 2025-11-06 18:49:43 +05:30
Tejas Tp
bfd5e4dbcb Update np.genfromtxt to use int and filling_values
Changed dtype from np.int to int and added filling_values parameter.
2025-11-06 18:45:05 +05:30
5 changed files with 215 additions and 215 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -131,7 +131,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)
@@ -548,7 +548,7 @@ s = StringIO('''1, 2, 3, 4, 5
, , 9,10,11
''')
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
print(Z)
```
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)

View File

@@ -131,7 +131,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)
@@ -548,7 +548,7 @@ s = StringIO('''1, 2, 3, 4, 5
, , 9,10,11
''')
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
print(Z)
```
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "af9e3994",
"id": "a3747e86",
"metadata": {},
"source": [
"# 100 numpy exercises\n",
@@ -18,7 +18,7 @@
},
{
"cell_type": "markdown",
"id": "76e99d49",
"id": "8b9ef9a4",
"metadata": {},
"source": [
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
@@ -26,7 +26,7 @@
},
{
"cell_type": "markdown",
"id": "8a54b21a",
"id": "792c1217",
"metadata": {},
"source": [
"Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
@@ -36,7 +36,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "670bb646",
"id": "541f746c",
"metadata": {},
"outputs": [],
"source": [
@@ -46,7 +46,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4ff49967",
"id": "d1743adb",
"metadata": {},
"outputs": [],
"source": [

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)
@@ -696,7 +696,7 @@ s = StringIO('''1, 2, 3, 4, 5
, , 9,10,11
''')
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
print(Z)
< q55