Skip to content

Commit

Permalink
Merge pull request #491 from dasilvaale/fix-from-cif-xyz
Browse files Browse the repository at this point in the history
Discrepancy between Phase.from_cif and Phase(structure)
  • Loading branch information
hakonanes authored Apr 21, 2024
2 parents 329d981 + c5254e9 commit ae09ee1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"name": "Viljar Johan Femoen",
"affiliation": "Norwegian University of Science and Technology"
},
{
"name": "Alessandra da Silva",
"orcid": "0000-0003-0465-504X"
},
{
"name": "Alexander Clausen",
"orcid": "0000-0002-9555-7455",
Expand Down
20 changes: 5 additions & 15 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@ All user facing changes to this project are documented in this file. The format
on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`__, and this project tries
its best to adhere to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`__.

Unreleased
==========

Added
-----

Changed
-------

Removed
-------

Deprecated
----------
2024-04-21 - version 0.12.1
===========================

Fixed
-----
- ``ax2qu`` and ``Quaternion.from_axes_angles()`` would raise if the input arrays were
broadcastable but the final dimension was ``1``. This has been fixed.

- ``Phase.from_cif()`` now correctly adjusts atom positions when forcing
``Phase.structure.lattice.base`` to use the crystal axes alignment ``e1 || a``,
``e3 || c*``. This bug was introduced in 0.12.0.

2024-04-13 - version 0.12.0
===========================
Expand Down
3 changes: 2 additions & 1 deletion orix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__name__ = "orix"
__version__ = "0.13.dev0"
__version__ = "0.12.1"
__author__ = "orix developers"
__author_email__ = "[email protected]"
__description__ = "orix is an open-source Python library for handling crystal orientation mapping data."
Expand All @@ -16,5 +16,6 @@
"Carter Francis",
"Simon Høgås",
"Viljar Johan Femoen",
"Alessandra da Silva",
"Alexander Clausen",
]
3 changes: 0 additions & 3 deletions orix/crystal_map/phase_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ def from_cif(cls, filename: str) -> Phase:
parser = p_cif.P_cif()
name = os.path.splitext(os.path.split(filename)[1])[0]
structure = parser.parseFile(filename)
lattice = structure.lattice
new_base = _new_structure_matrix_from_alignment(lattice.base, x="a", z="c*")
lattice.setLatBase(new_base)
space_group = parser.spacegroup.number
return cls(name, space_group, structure=structure)

Expand Down
9 changes: 8 additions & 1 deletion orix/tests/test_phase_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with orix. If not, see <http://www.gnu.org/licenses/>.

from diffpy.structure import Atom, Lattice, Structure
from diffpy.structure import Atom, Lattice, Structure, loadStructure
from diffpy.structure.spacegroups import GetSpaceGroup
import numpy as np
import pytest
Expand Down Expand Up @@ -396,6 +396,13 @@ def test_from_cif(self, cif_file):
lattice.base, [[15.5, 0, 0], [0, 4.05, 0], [-1.779, 0, 6.501]], atol=1e-3
)

def test_from_cif_same_structure(self, cif_file):
phase1 = Phase.from_cif(cif_file)
structure = loadStructure(cif_file)
phase2 = Phase(structure=structure)
assert np.allclose(phase1.structure.lattice.base, phase2.structure.lattice.base)
assert np.allclose(phase1.structure.xyz, phase2.structure.xyz)


class TestPhaseList:
@pytest.mark.parametrize("empty_input", [(), [], {}])
Expand Down

0 comments on commit ae09ee1

Please sign in to comment.