In [183]: r1 = lambda t: np.array([2*t, 1])
...: r2 = lambda t: np.array([2*t, 1+0*t])
...: t = np.linspace(0, 1)
In [184]: r1(t)
Out[184]:
array([array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531,
0.20408163, 0.24489796, 0.28571429, 0.32653061, 0.36734694,
0.40816327, 0.44897959, 0.48979592, 0.53061224, 0.57142857,
0.6122449 , 0.65306122, 0.69387755, 0.73469388, 0.7755102 ,
0.81632653, 0.85714286, 0.89795918, 0.93877551, 0.97959184,
1.02040816, 1.06122449, 1.10204082, 1.14285714, 1.18367347,
1.2244898 , 1.26530612, 1.30612245, 1.34693878, 1.3877551 ,
1.42857143, 1.46938776, 1.51020408, 1.55102041, 1.59183673,
1.63265306, 1.67346939, 1.71428571, 1.75510204, 1.79591837,
1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]),
1], dtype=object)
In [185]: r2(t)
Out[185]:
array([[0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531,
0.20408163, 0.24489796, 0.28571429, 0.32653061, 0.36734694,
0.40816327, 0.44897959, 0.48979592, 0.53061224, 0.57142857,
0.6122449 , 0.65306122, 0.69387755, 0.73469388, 0.7755102 ,
0.81632653, 0.85714286, 0.89795918, 0.93877551, 0.97959184,
1.02040816, 1.06122449, 1.10204082, 1.14285714, 1.18367347,
1.2244898 , 1.26530612, 1.30612245, 1.34693878, 1.3877551 ,
1.42857143, 1.46938776, 1.51020408, 1.55102041, 1.59183673,
1.63265306, 1.67346939, 1.71428571, 1.75510204, 1.79591837,
1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ],
[1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ]])
In [186]: r1(t).shape
Out[186]: (2,)
In [187]: r2(t).shape
Out[187]: (2, 50)
r2
组合两个t
形状匹配的数组 (50,),因此结果是一个 (2,50) 形状的数值数组。
r1
将 (50,) 数组与标量组合在一起1
。结果是一个 2 元素数组 object dtype。看到显示器1
末端的悬空了吗?r1
混合不同大小的元素会产生一个类似数组的列表,因为它不能像r2