Hi,
Thanks for replying. I was using:
```
from numpy.lib import recfunctions as rfn
xyz = rfn.structured_to_unstructured(atoms[["x", "y", "z"]])
xyz = xyz @ transform.T
atoms[["x", "y", "z"]] = rfn.unstructured_to_structured(
xyz, dtype=atoms[["x", "y", "z"]].dtype
)
```
But I think this is creating a copy not a view.
Anyway, I did the following:
```
fields = atoms.dtype.names
idxx, idxz = fields.index("x"), fields.index("z")
xyz_field = ("xyz", (np.float64, (3,)))
# create a new dtype with previous fields, xyz and next fields
new_fields = (
[(n, atoms.dtype[n]) for n in fields[:idxx]]
+ [xyz_field]
+ [(n, atoms.dtype[n]) for n in fields[idxz + 1 :]]
) # usually x, y, z fields are one next to the other
new_dtype = np.dtype(new_fields)
xyz = atoms.view(new_dtype)["xyz"]
xyz[:] = xyz @ transform.T
```
And works fine. I guess there is no direct way computing the rotation without a view.
Thanks Marten,
Best,
Abel
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.