Skip to content

Retain miller symmetry information - #682

Open
argerlt wants to merge 8 commits into
pyxem:developfrom
argerlt:Retain-miller-symmetry-information
Open

argerlt wants to merge 8 commits into
pyxem:developfrom
argerlt:Retain-miller-symmetry-information

Conversation

@argerlt

@argerlt argerlt commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description of the change

Solves #501. @hakonanes and/or @viljarjf , let me know what you think of this approach. if we like it, I will address the failing unit tests add some new ones, and include documentation.

Main features of this PR:

  • The Miller dunder methods __neg__, __add__, and __sub__ no longer discard phase information or coordinate preference
  • Warnings have been added using the new logger feature that alert users when symmetry or coordinate frame mismatches occur.
  • Simplification of Vector3d._radd__, Vector3d._rsub__ , Vector3d._sub__ and Vector3d.__rmul__ to avoid repeating code and allow inheriting phase information from a Millerclass.

Progress of the PR

Minimal example of the bug fix or new feature

from orix.vector import Miller, Vector3d
from orix.crystal_map import Phase

p1 = Phase(point_group="m-3m")
p2 = Phase(point_group="6mm")

m_xyz = Miller(xyz=[1, 2, 1], phase=p1)
m_hkl = Miller(hkl=[1, 2, 1], phase=p1)
m_hex_hkl = Miller(hkl=[1, 2, 1], phase=p2)

v = Vector3d([1,2,3])

# Negation copies symmetry and coordinate format
print(m_xyz)
print(-m_xyz)

print(m_hkl)
print(-m_hkl)

# Adding mismatched crystal vectors throws appropriate warnings
print(m_xyz + m_hkl)
print(m_hkl + m_hex_hkl)
print(m_hex_hkl + m_xyz)

# combining crystal and real space vectors always returns a crystal vector,
# but with a warning.
print(m_xyz + v)
print(v + m_xyz)
print(m_xyz - v)
print(v - m_xyz)

# additionally, sample vectors are assumed to have the same coordinate format as
# the crystal vector they are being combined with.
print(m_hkl + v)
print(v + m_hkl)
print(m_hkl - v)
print(v - m_hkl)

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.

@argerlt

argerlt commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

pre-commit.ci autofix

@argerlt argerlt linked an issue Sep 9, 2026 that may be closed by this pull request
@argerlt
argerlt force-pushed the Retain-miller-symmetry-information branch from 50e7905 to 30323bc Compare September 9, 2026 00:34
@argerlt

argerlt commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addendum: Maybe we don't want to get into it now, but the latest commit would eliminate the need for #499 and #500 as well.

IMO, the related thread on diffsims was about if you should or shouldn't do the given example calculation, which is an important question for Diffsims, but handling it on the ORIX side is a far simpler single-line fix. @viljarjf 's original solution is basically what I did here to get Vector+Miller to always return a Miller, so it seems like a great solution now, whereas I believe #499 breaks some newer orix features.

If anyone disagrees, let me know and I'll revert it.

@argerlt argerlt linked an issue Sep 9, 2026 that may be closed by this pull request
@argerlt argerlt mentioned this pull request Sep 9, 2026
@argerlt argerlt added the help-wanted A little help with this would be nice label Sep 15, 2026
@argerlt
argerlt force-pushed the Retain-miller-symmetry-information branch from 30323bc to a73522a Compare October 16, 2026 21:55
@argerlt

argerlt commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

classes work as expected now, just need to write unit tests and examples.

@argerlt argerlt added status: waiting-for-author This pull request has comments the author must address and removed help-wanted A little help with this would be nice labels Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-author This pull request has comments the author must address

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Miller dunder methods silently discards the phase Make Bug Fix Release

1 participant