2021年3月25日星期四

Accessing contents of numpy.ndarray fields

I have created an ndarray from a sympy lambdify function in python and the actual values I need are tucked away within this array field of my result variable. To be clear, each index of array along axis=0 corresponds to the first derivative of a 7th order time polynomial at a particular time instant:

enter image description here

In my lambdify function, I passed a size-33 element time-vector and was expecting an 8x33 or 33x8 result but instead, it pushed my output to this array field and I am having difficulty accessing it. Right now, I can only access it by doing result[0], result[1], etc. but this is tedious as I can only access everything one at a time, implying that a loop is the only way to access everything. This is not the behavior I'd expect of an ndarray:

enter image description here

Can someone explain what is going on here and if possible, how I can access this array field so that I can vectorize any subsequent operations? My goal is to stack each element in array along axis=0 and compute subsequent derivatives and stack them according to their respective time.

https://stackoverflow.com/questions/66809323/accessing-contents-of-numpy-ndarray-fields March 26, 2021 at 08:15AM

没有评论:

发表评论