Regenerate all the files
This commit is contained in:
parent
a4ac12cdc6
commit
4b759efce8
File diff suppressed because it is too large
Load Diff
@ -3,15 +3,12 @@
|
||||
|
||||
# 100 numpy exercises
|
||||
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack
|
||||
overflow
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack overflow
|
||||
and in the numpy documentation. The goal of this collection is to offer a quick reference for both old
|
||||
and new
|
||||
users but also to provide a set of exercises for those who teach.
|
||||
and new users but also to provide a set of exercises for those who teach.
|
||||
|
||||
|
||||
If you find an error or think you've a better way to
|
||||
solve some of them, feel
|
||||
If you find an error or think you've a better way to solve some of them, feel
|
||||
free to open an issue at <https://github.com/rougier/numpy-100>.
|
||||
File automatically generated. See the documentation to update questions/answers/hints programmatically.
|
||||
|
||||
@ -221,7 +218,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
|
||||
|
||||
#### 85. Create a 2D array subclass such that Z[i,j] == Z[j,i] (★★★)
|
||||
|
||||
#### 86. Consider a set of p matrices wich shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
#### 86. Consider a set of p matrices with shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
|
||||
#### 87. Consider a 16x16 array, how to get the block-sum (block size is 4x4)? (★★★)
|
||||
|
||||
|
@ -3,15 +3,12 @@
|
||||
|
||||
# 100 numpy exercises
|
||||
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack
|
||||
overflow
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack overflow
|
||||
and in the numpy documentation. The goal of this collection is to offer a quick reference for both old
|
||||
and new
|
||||
users but also to provide a set of exercises for those who teach.
|
||||
and new users but also to provide a set of exercises for those who teach.
|
||||
|
||||
|
||||
If you find an error or think you've a better way to
|
||||
solve some of them, feel
|
||||
If you find an error or think you've a better way to solve some of them, feel
|
||||
free to open an issue at <https://github.com/rougier/numpy-100>.
|
||||
File automatically generated. See the documentation to update questions/answers/hints programmatically.
|
||||
|
||||
@ -221,7 +218,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
|
||||
`hint: stride_tricks.as_strided, from numpy.lib.stride_tricks import sliding_window_view (np>=1.20.0)`
|
||||
#### 85. Create a 2D array subclass such that Z[i,j] == Z[j,i] (★★★)
|
||||
`hint: class method`
|
||||
#### 86. Consider a set of p matrices wich shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
#### 86. Consider a set of p matrices with shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
`hint: np.tensordot`
|
||||
#### 87. Consider a 16x16 array, how to get the block-sum (block size is 4x4)? (★★★)
|
||||
`hint: np.add.reduceat, from numpy.lib.stride_tricks import sliding_window_view (np>=1.20.0)`
|
||||
|
@ -3,15 +3,12 @@
|
||||
|
||||
# 100 numpy exercises
|
||||
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack
|
||||
overflow
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack overflow
|
||||
and in the numpy documentation. The goal of this collection is to offer a quick reference for both old
|
||||
and new
|
||||
users but also to provide a set of exercises for those who teach.
|
||||
and new users but also to provide a set of exercises for those who teach.
|
||||
|
||||
|
||||
If you find an error or think you've a better way to
|
||||
solve some of them, feel
|
||||
If you find an error or think you've a better way to solve some of them, feel
|
||||
free to open an issue at <https://github.com/rougier/numpy-100>.
|
||||
File automatically generated. See the documentation to update questions/answers/hints programmatically.
|
||||
|
||||
@ -170,12 +167,6 @@ Z = np.zeros((8,8),dtype=int)
|
||||
Z[1::2,::2] = 1
|
||||
Z[::2,1::2] = 1
|
||||
print(Z)
|
||||
|
||||
# Alternative solution: Using reshaping
|
||||
arr = np.ones(64,dtype=int)
|
||||
arr[::2]=0
|
||||
arr = arr.reshape((8,8))
|
||||
print(arr)
|
||||
```
|
||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||
`hint: np.unravel_index`
|
||||
@ -1013,7 +1004,7 @@ S = symetric(np.random.randint(0,10,(5,5)))
|
||||
S[2,3] = 42
|
||||
print(S)
|
||||
```
|
||||
#### 86. Consider a set of p matrices wich shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
#### 86. Consider a set of p matrices with shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
`hint: np.tensordot`
|
||||
|
||||
```python
|
||||
|
@ -3,15 +3,12 @@
|
||||
|
||||
# 100 numpy exercises
|
||||
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack
|
||||
overflow
|
||||
This is a collection of exercises that have been collected in the numpy mailing list, on stack overflow
|
||||
and in the numpy documentation. The goal of this collection is to offer a quick reference for both old
|
||||
and new
|
||||
users but also to provide a set of exercises for those who teach.
|
||||
and new users but also to provide a set of exercises for those who teach.
|
||||
|
||||
|
||||
If you find an error or think you've a better way to
|
||||
solve some of them, feel
|
||||
If you find an error or think you've a better way to solve some of them, feel
|
||||
free to open an issue at <https://github.com/rougier/numpy-100>.
|
||||
File automatically generated. See the documentation to update questions/answers/hints programmatically.
|
||||
|
||||
@ -170,12 +167,6 @@ Z = np.zeros((8,8),dtype=int)
|
||||
Z[1::2,::2] = 1
|
||||
Z[::2,1::2] = 1
|
||||
print(Z)
|
||||
|
||||
# Alternative solution: Using reshaping
|
||||
arr = np.ones(64,dtype=int)
|
||||
arr[::2]=0
|
||||
arr = arr.reshape((8,8))
|
||||
print(arr)
|
||||
```
|
||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||
|
||||
@ -1013,7 +1004,7 @@ S = symetric(np.random.randint(0,10,(5,5)))
|
||||
S[2,3] = 42
|
||||
print(S)
|
||||
```
|
||||
#### 86. Consider a set of p matrices wich shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
#### 86. Consider a set of p matrices with shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)
|
||||
|
||||
|
||||
```python
|
||||
|
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fc29ba19",
|
||||
"id": "e06c1964",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 100 numpy exercises\n",
|
||||
@ -18,7 +18,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c71c938e",
|
||||
"id": "c108c1c4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
||||
@ -26,7 +26,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9295ebad",
|
||||
"id": "2aefe09b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Run the `initialize.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": "75ba9fda",
|
||||
"id": "55c8f855",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -46,7 +46,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5e130ff3",
|
||||
"id": "8f1e8a4a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
Loading…
Reference in New Issue
Block a user