- ogrid VS mgrid
- ogrid
np.ogrid[row(list of size), column(a single list)]
np.ogrid[0:3, 0:5]
>>>
array([[0],
[1],
[2]])
array([[0, 1, 2, 3, 4]])
- mgrid
np.mgrid[row(filled with the same number by row), column(filled with the same number by column)]
np.mgrid[0:3, 0:5]
>>>
array([[[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2]],
[[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]]])
- ogrid VS mgrid with j(evenly spaced)
np.ogrid[row-start:end:piecesj,column-start:end:piecesj]
- ogrid
np.ogrid[-1:1:3j, -1:1:5j]
>>>
[array([[-1.],
[ 0.],
[ 1.]]), array([[-1. , -0.5, 0. , 0.5, 1. ]])]
- mgrid
np.mgrid[-1:1:3j, -1:1:5j]
>>>
array([[[-1. , -1. , -1. , -1. , -1. ],
[ 0. , 0. , 0. , 0. , 0. ],
[ 1. , 1. , 1. , 1. , 1. ]],
[[-1. , -0.5, 0. , 0.5, 1. ],
[-1. , -0.5, 0. , 0.5, 1. ],
[-1. , -0.5, 0. , 0.5, 1. ]]])
- ogrid VS mgrid Without j(considered as stack)
- ogrid
np.ogrid[-1:1:3, -1:1:5]
>>>
[array([[-1]]), array([[-1]])]
- mgrid
np.mgrid[-1:1:3, -1:1:5]
>>>
array([[[-1]],
[[-1]]])
'Analyze Data > Python Libraries' 카테고리의 다른 글
numpy-zeros, zeros_like (0) | 2024.03.22 |
---|---|
numpy-pad (0) | 2023.12.26 |
EasyDict (0) | 2023.10.18 |
numpy-concatenate (0) | 2023.06.07 |
numpy-identity (0) | 2023.06.02 |