2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -2,7 +2,7 @@
In [1]:
```
```py
import numpy as np
```
@@ -11,7 +11,7 @@ import numpy as np
In [2]:
```
```py
a = np.array([[ 0, 0, 0],
[10,10,10],
[20,20,20],
@@ -26,7 +26,7 @@ a + b
Out[2]:
```
```py
array([[ 0, 1, 2],
[10, 11, 12],
[20, 21, 22],
@@ -37,7 +37,7 @@ array([[ 0, 1, 2],
In [3]:
```
```py
b = np.array([0,1,2])
a + b
@@ -46,7 +46,7 @@ a + b
Out[3]:
```
```py
array([[ 0, 1, 2],
[10, 11, 12],
[20, 21, 22],
@@ -61,7 +61,7 @@ array([[ 0, 1, 2],
In [4]:
```
```py
a = np.array([0,10,20,30])
a.shape = 4,1
a
@@ -70,7 +70,7 @@ a
Out[4]:
```
```py
array([[ 0],
[10],
[20],
@@ -79,27 +79,27 @@ array([[ 0],
In [5]:
```
```py
b
```
Out[5]:
```
```py
array([0, 1, 2])
```
In [6]:
```
```py
a + b
```
Out[6]:
```
```py
array([[ 0, 1, 2],
[10, 11, 12],
[20, 21, 22],
@@ -129,7 +129,7 @@ array([[ 0, 1, 2],
In [7]:
```
```py
a = np.array([0,10,20,30])
a.shape
@@ -137,31 +137,31 @@ a.shape
Out[7]:
```
```py
(4L,)
```
In [8]:
```
```py
b.shape
```
Out[8]:
```
```py
(3L,)
```
In [9]:
```
```py
a + b
```
```
```py
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-f96fb8f649b6> in <module>()
@@ -174,14 +174,14 @@ ValueError: operands could not be broadcast together with shapes (4,) (3,)
In [10]:
```
```py
a[:, np.newaxis] + b
```
Out[10]:
```
```py
array([[ 0, 1, 2],
[10, 11, 12],
[20, 21, 22],
@@ -192,41 +192,41 @@ array([[ 0, 1, 2],
In [11]:
```
```py
x = np.linspace(-.5,.5, 21)
```
In [12]:
```
```py
y = x[:, np.newaxis]
```
In [13]:
```
```py
x.shape
```
Out[13]:
```
```py
(21L,)
```
In [14]:
```
```py
y.shape
```
Out[14]:
```
```py
(21L, 1L)
```
@@ -234,14 +234,14 @@ Out[14]:
In [15]:
```
```py
radius = np.sqrt(x ** 2 + y ** 2)
```
In [16]:
```
```py
import matplotlib.pyplot as plt
%matplotlib inline
@@ -251,7 +251,7 @@ plt.imshow(radius)
Out[16]:
```
```py
<matplotlib.image.AxesImage at 0xa2cb358>
```