-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Describe the bug
Rotation of a ReciprocalLatticeVector, g, with a Rotation from orix, R, throws an error. The multiplication uses Quaternion.__mul__(). There, the other being multiplied, here g, fails the test isinstance(other, Miller) and thus phase information is not passed on when creating the rotated ReciprocalLatticeVector in its __init__().
Code in orix: https://github.com/pyxem/orix/blob/a1be2697dc0cf02974b00d06d94272de77efeafa/orix/quaternion/quaternion.py#L238-L243
Minimal example
from orix.crystal_map import Phase
from orix.quaternion import Rotation
from diffsims.crystallography import ReciprocalLatticeVector
phase = Phase(point_group="m-3m")
g = ReciprocalLatticeVector(phase, [1, 1, 1])
R = Rotation.random()
g1 = R * gthrows
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File /Users/hakon/kode/scratches/ds_scratch.py:5
2 R = Rotation.random()
3 om = R.to_matrix()
----> 5 g1 = R * g
6 #g2 = g.rotate_from_matrix(om)
File /opt/homebrew/Caskroom/miniforge/base/envs/ds/lib/python3.11/site-packages/orix/quaternion/rotation.py:123, in Rotation.__mul__(self, other)
121 return Q
122 if isinstance(other, Vector3d):
--> 123 v = Quaternion(self) * other
124 improper = (self.improper * np.ones(other.shape)).astype(bool)
125 v[improper] = -v[improper]
File /opt/homebrew/Caskroom/miniforge/base/envs/ds/lib/python3.11/site-packages/orix/quaternion/quaternion.py:243, in Quaternion.__mul__(self, other)
241 return m
242 else:
--> 243 return other.__class__(v)
244 return NotImplemented
File ~/kode/personal/diffsims/diffsims/crystallography/reciprocal_lattice_vector.py:105, in ReciprocalLatticeVector.__init__(self, phase, xyz, hkl, hkil)
103 def __init__(self, phase, xyz=None, hkl=None, hkil=None):
104 self.phase = phase
--> 105 self._raise_if_no_point_group()
107 if np.sum([i is not None for i in [xyz, hkl, hkil]]) != 1:
108 raise ValueError(\"Exactly one of `xyz`, `hkl`, or `hkil` must be passed\")
File ~/kode/personal/diffsims/diffsims/crystallography/reciprocal_lattice_vector.py:1265, in ReciprocalLatticeVector._raise_if_no_point_group(self)
1259 def _raise_if_no_point_group(self):
1260 \"\"\"Raise ValueError if the phase attribute has no point group
1261 set.
1262
1263 \"\"\"
-> 1265 if self.phase.point_group is None:
1266 raise ValueError(f\"The phase {self.phase} must have a point group set\")
AttributeError: 'numpy.ndarray' object has no attribute 'point_group'"The rotated ReciprocalLatticeVector with the phase information intact should be returned.
I'm not 100% sure how to fix this. ReciprocalLatticeVector should not subclass Miller, as the coordinates of the former can only be (hkl). Any input would be appreciated.