I'm using structured arrays to store atoms data produced by LAMMPS (I'm using a structured array that follows its format). I need to rotate the positions:
``` import numpy as np transform = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.float64) dtype = np.dtype([("x", np.float64), ("y", np.float64), ("z", np.float64)]) # real case with more fields, integers, bools, strings atoms = np.array( [ (0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (1.0, 1.0, 1.0), ], dtype=dtype, ) atoms[["x", "y", "z"]] = atoms[["x", "y", "z"]] @ transform.T ``` But this produces: ``` Traceback (most recent call last): File "c:\Users\acgc99\Desktop\rotation.py", line 16, in <module> atoms[["x", "y", "z"]] = atoms[["x", "y", "z"]] @ transform.T ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ numpy._core._exceptions._UFuncNoLoopError: ufunc 'matmul' did not contain a loop with signature matching types (dtype([('x', '<f8'), ('y', '<f8'), ('z', '<f8')]), dtype('float64')) -> None ``` I can convert to unstructured arrays, but I guess that doing that change multiple times is not efficient when working with tens of millions of atoms. _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: arch...@mail-archive.com