pyxem / orix

Analysing crystal orientations and symmetry in Python
https://orix.readthedocs.io
GNU General Public License v3.0
78 stars 45 forks source link

BugFix: Allow get_kwargs for setting kwargs on __mul__ #499

Open CSSFrancis opened 2 months ago

CSSFrancis commented 2 months ago

Description of the change

This should fix (part) of the problems upstream with https://github.com/pyxem/diffsims/issues/211 by allowing the function get_kwargs to be overwritten in subclasses and change the order/what is passed to the init fuction.

Minimal example of the bug fix or new feature (This now works)

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 * g

# CHanges to RLV
# ---------------- 

    def get_kwargs(self, new_data, *args, **kwargs):
        return dict(phase=self.phase, xyz=new_data)

For reviewers

hakonanes commented 2 months ago

Thanks for suggesting a fix to the issue in diffsims. But, I've raised some doubts regarding our approach in the referenced issue https://github.com/pyxem/diffsims/issues/211#issuecomment-2099218511.

CSSFrancis commented 2 months ago

@hakonanes I think this should be possible. It works quite nicely with everything and makes the logic much simpler. Otherwise we end up having to struggle to track the rotation alongside the RLV from diffsims --> pyxem and it gets complicated.