Skip to content

Commit

Permalink
Merge pull request #496 from hakonanes/main-into-develop-post-0.12.1
Browse files Browse the repository at this point in the history
Main into develop post 0.12.1
  • Loading branch information
hakonanes authored Apr 21, 2024
2 parents 856491e + 8043008 commit 5331127
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 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
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Fixed
-----


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.13.dev1"
__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
2 changes: 1 addition & 1 deletion orix/quaternion/_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def ax2qu(axes: np.ndarray, angles: np.ndarray) -> np.ndarray:

if axes.shape[-1] != 3:
raise ValueError("Final dimension of axes array must be 3.")
if angles.shape[-1] != 1 or angles.shape == (1,):
if angles.shape[-1] != 1 or angles.shape == (1,) or axes.shape[:-1] == angles.shape:
angles = angles.reshape(angles.shape + (1,))

axes_shape = axes.shape[:-1]
Expand Down
5 changes: 4 additions & 1 deletion orix/tests/quaternion/test_quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,10 @@ class TestFromToAxesAngles:
axis-angle vectors.
"""

def test_from_axes_angles(self, rotations):
@pytest.mark.parametrize("extra_dim", [True, False])
def test_from_axes_angles(self, rotations, extra_dim):
if extra_dim:
rotations = rotations.__class__(rotations.data[..., np.newaxis, :])
ax = AxAngle.from_rotation(rotations)
with pytest.warns(np.VisibleDeprecationWarning):
q2 = Quaternion.from_neo_euler(ax)
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 5331127

Please sign in to comment.