Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hakonanes
Copy link
Member

@hakonanes hakonanes commented Mar 4, 2023

Description of the change

This is a fix for a bug spotted by @Erlendos12 in pyxem/kikuchipy#620. When a CrystalMap is initialized with a phase ID array with more IDs than there are phases in the given phase list, the returned map does not link the phase ID array with the correct phase in the phase list. It does with this fix. See below for an example.

I'd like to release a 0.11.1 patch with this fix as soon as this PR is merged onto main, if that is OK with people.

Progress of the PR

Minimal example of the bug fix or new feature

>>> import numpy as np
>>> from orix.crystal_map import CrystalMap, PhaseList
>>> from orix.quaternion import Rotation
>>> pl = PhaseList(ids=[1], names=["b"], space_groups=[225])
>>> pl
Id  Name  Space group  Point group  Proper point group     Color
 1     b        Fm-3m         m-3m                 432  tab:blue
>>> phase_id = np.array([0, 0, 1, 1, 1, 3])
>>> xmap = CrystalMap(
...     rotations=Rotation.identity(phase_id.size),
...     is_in_data=phase_id == 1,
...     phase_list=pl,
...     phase_id=phase_id,
... )

# Output with 0.11.0

>>> xmap
Phase  Orientations  Name  Space group  Point group  Proper point group       Color
    1    3 (100.0%)  None         None         None                None  tab:orange
Properties: 
Scan unit: px
>>> xmap.phases
Id  Name  Space group  Point group  Proper point group       Color
 0     b        Fm-3m         m-3m                 432    tab:blue
 1  None         None         None                None  tab:orange
 3  None         None         None                None   tab:green


# Output after fix (with upcoming 0.11.1)

>>> xmap
Phase  Orientations  Name  Space group  Point group  Proper point group     Color
    1    3 (100.0%)     b        Fm-3m         m-3m                 432  tab:blue
Properties: 
Scan unit: px
>>> xmap.phases
Id  Name  Space group  Point group  Proper point group       Color
 0  None         None         None                None  tab:orange
 1     b        Fm-3m         m-3m                 432    tab:blue
 3  None         None         None                None   tab:green

This example is also an added test.

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@hakonanes hakonanes added the bug Something isn't working label Mar 4, 2023
@hakonanes hakonanes added this to the v0.11.1 milestone Mar 4, 2023
@hakonanes hakonanes marked this pull request as draft March 4, 2023 18:53
@hakonanes hakonanes requested a review from pc494 March 5, 2023 17:34
@hakonanes hakonanes marked this pull request as ready for review March 5, 2023 19:04
@hakonanes hakonanes requested a review from harripj March 7, 2023 09:52
Copy link
Collaborator

@harripj harripj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping! Looks good to me, also happy with the patch release. I'll leave the merge to you 😊

@hakonanes
Copy link
Member Author

Thanks, Patrick! Tomorrow, Wednesday, I'll update the changelog date, merge and release.

@hakonanes hakonanes force-pushed the fix-xmap-init-sparse-phaselist branch from 1c1fb70 to 110a8a7 Compare March 14, 2023 08:55
@hakonanes hakonanes merged commit 6028c89 into pyxem:main Mar 14, 2023
@hakonanes hakonanes deleted the fix-xmap-init-sparse-phaselist branch March 14, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants