-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure atom positions are expressed in the new basis when initializing Phase with structure #469
Conversation
@viljarjf would you be comfortable writing a test case for this? If so, I'll wait for that and then get my crystallography hat on to check this works as it needs to. |
@viljarjf I would just add the example in as a test. It at least makes sure that we explicitly know what basis we are working in and if for some reason diffpy changes then we would know. |
I added a test now, a cubic lattice passes with the old code but the two non-cubic lattices failed. All three pass with the fix |
@viljarjf Just a note that you need to run both black and isort, let me know if you need help doing that. @pc494 do you want to allow pre-commit similar to As far as the failing tests go. They seem unrelated. @pc494 You can rerun the tests if you would like and it might allow them to pass otherwise there is a different bug. |
Both, I'm going to check this out today to refactor the testing a little bit and I'll get isort + black etc run then as well. |
@pc494 This needs to be added to the Changelog as well |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @viljarjf, @CSSFrancis I got very lost in the tests here and, given the pace of change in orix I wanted to be super sure on what was going on. Does the refactor I've written make sense?
# Ensure atom positions are expressed in the new basis | ||
old_xyz_cartn = value.xyz_cartn | ||
value.lattice.setLatBase(new_matrix) | ||
value.xyz_cartn = old_xyz_cartn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems okay to me, but I'm mainly taking the correctness of this on faith from @hakonanes in pyxem/diffsims#203 (comment)
@hakonanes I tested this vs Kikchipy and the tests appear to be passing. |
@pc494 any idea why the documentation is failing? |
I'm going to tidy this up with a view to merge later today. Hopefully, the docs will figure themselves out,.. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Given the current state of play, I am going to merge this, with new issues raised about both the RTD build and the contributors list. |
Fixes (part of) pyxem/diffsims#203
Description of the change
When initializing a
Phase
with adiffpy.structure.Structure
, the lattice is transformed to orix's standard coordinate system. However, the atoms are still expressed as if they were in the old lattice.By taking the cartesian positions of the atoms before changing the lattice, and using those to set the new positions, the change of basis is accounted for.
All tests pass, but I don't think this was tested for previously. It probably should.
Progress of the PR
Minimal example of the bug fix or new feature
Output before:
Output with this PR:
For reviewers
__init__.py
.section in
CHANGELOG.rst
.__credits__
inorix/__init__.py
and in.zenodo.json
.