У меня есть ndarray компонентов x и y значений 2D-скорости объекта, например:
(Pdb) p highspeedentries
array([[ 0. , 52.57],
[-40.58, 70.89],
[-57.32, 76.47],
[-57.92, 65.1 ],
[-52.47, 96.68],
[-45.58, 77.12],
[-37.83, 69.52]])
(Pdb) p type(highspeedentries)
<class 'numpy.ndarray'>
Я должен проверить, есть ли какая-либо строка, содержащая значение выше 55 для первого и второго компонентов в строке. Мне также нужно взять абсолютное значение для любого отрицательного компонента скорости, но сначала я попробовал следующее, и все они дают ошибки.
(Pdb) p highspeedentries[highspeedentries[:,1] > 55 and highspeedentries[0,:] > 55]
*** ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
(Pdb) p highspeedentries[highspeedentries[:,1] > 55 & highspeedentries[0,:] > 55]
*** TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be
safely coerced to any supported types according to the casting rule ''safe''
(Pdb) p highspeedentries[np.logical_and(highspeedentries[:,1] > 55, highspeedentries[0,:] > 55)]
*** ValueError: operands could not be broadcast together with shapes (7,) (2,)
highspeedentries[0,:] > 55
заменить наhighspeedentries[:,0] > 55
- person bubble   schedule 14.11.2019