|
@ -1464,8 +1464,8 @@ NumPy |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
|
value = <array>.min([axis]) |
|
|
|
|
|
index = <array>.argmin([axis]) |
|
|
|
|
|
|
|
|
value = <array>.min([axis]) |
|
|
|
|
|
index = <array>.argmin([axis]) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
@ -1480,17 +1480,17 @@ index = <array>.argmin([axis]) |
|
|
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1) |
|
|
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1) |
|
|
right = [ 0.1 , 0.6 , 0.8 ] # Shape: (3) |
|
|
right = [ 0.1 , 0.6 , 0.8 ] # Shape: (3) |
|
|
``` |
|
|
``` |
|
|
1. If array shapes differ, left-pad the smaller shape with ones. |
|
|
|
|
|
|
|
|
**1. If array shapes differ, left-pad the smaller shape with ones.** |
|
|
```python |
|
|
```python |
|
|
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1) |
|
|
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1) |
|
|
right = [[0.1 , 0.6 , 0.8]] # Shape: (1, 3) <- ! |
|
|
right = [[0.1 , 0.6 , 0.8]] # Shape: (1, 3) <- ! |
|
|
``` |
|
|
``` |
|
|
2. If any dimensions differ in size, expand the ones that have size 1 by duplicating their elements. |
|
|
|
|
|
|
|
|
**2. If any dimensions differ in size, expand the ones that have size 1 by duplicating their elements.** |
|
|
```python |
|
|
```python |
|
|
left = [[0.1, 0.1, 0.1], [0.6, 0.6, 0.6], [0.8, 0.8, 0.8]] # Shape: (3, 3) <- ! |
|
|
left = [[0.1, 0.1, 0.1], [0.6, 0.6, 0.6], [0.8, 0.8, 0.8]] # Shape: (3, 3) <- ! |
|
|
right = [[0.1, 0.6, 0.8], [0.1, 0.6, 0.8], [0.1, 0.6, 0.8]] # Shape: (3, 3) <- ! |
|
|
right = [[0.1, 0.6, 0.8], [0.1, 0.6, 0.8], [0.1, 0.6, 0.8]] # Shape: (3, 3) <- ! |
|
|
``` |
|
|
``` |
|
|
3. If neither non-matching dimension has size 1, rise an error. |
|
|
|
|
|
|
|
|
**3. If neither non-matching dimension has size 1, rise an error.** |
|
|
|
|
|
|
|
|
### Example |
|
|
### Example |
|
|
**For each point returns index of its nearest point: `[0.1, 0.6, 0.8] => [1, 2, 1]`.** |
|
|
**For each point returns index of its nearest point: `[0.1, 0.6, 0.8] => [1, 2, 1]`.** |
|
|