From the following test code, it is easy to understand the x.sum() and x.sum(axis=0).
Question 1:
How to calculate each value in x.sum(axis=1)?
Question 2:
What does the value of np.angle(x, deg=True) mean, and how np.angle works for an array?
test code:
import numpy as np
x = np.arange(27).reshape((3,3,3))
x
output:
array([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
[[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 23],
[24, 25, 26]]])
test code:
x.sum()
output:
351
test code:
x.sum(axis=0)
output:
array([[27, 30, 33],
[36, 39, 42],
[45, 48, 51]])
test code:
x.sum(axis=1)
output:
array([[ 9, 12, 15],
[36, 39, 42],
[63, 66, 69]])
test code:
x.sum(axis=2)
output:
array([[ 3, 12, 21],
[30, 39, 48],
[57, 66, 75]])
test code:
y = np.angle(x, deg=True)
y
output:
array([[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]])
