Skip to content

Commit

Permalink
Merge pull request #512 from hakonanes/main-into-develop-post-0.13.0
Browse files Browse the repository at this point in the history
Main into develop post 0.13.0
  • Loading branch information
hakonanes authored Sep 4, 2024
2 parents 688ee4a + 7f1898f commit b327412
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 92 deletions.
22 changes: 18 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ its best to adhere to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>
Unreleased
==========

Added
-----

Changed
-------

Deprecated
----------

Removed
-------

Fixed
-----

2024-09-03 - version 0.13.0
===========================

Added
-----
- We can now read 2D crystal maps from Channel Text Files (CTFs) using ``io.load()``.
Expand All @@ -30,10 +48,6 @@ Deprecated
- ``loadang()`` and ``loadctf()`` are deprecated and will be removed in the next minor
release. Please use ``io.load()`` instead.

Fixed
-----


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

Expand Down
4 changes: 2 additions & 2 deletions doc/user/related_projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ find useful:
orix depends on numpy-quaternion for quaternion multiplication.
- `texture <https://github.com/usnistgov/texture>`_: Python scripts for analysis of
crystallographic texture.
- `pymicro <https://pymicro.readthedocs.io>`_`: Python package to work with material
- `pymicro <https://pymicro.readthedocs.io>`_: Python package to work with material
microstructures and 3D data sets.
- `DREAM.3D <https://dream3d.io/>`_`: C++ library to reconstruct, instatiate, quantify,
- `DREAM.3D <https://dream3d.io/>`_: C++ library to reconstruct, instatiate, quantify,
mesh, handle and visualize multidimensional (3D), multimodal data (mainly EBSD
orientation data).
2 changes: 1 addition & 1 deletion orix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__name__ = "orix"
__version__ = "0.13.dev1"
__version__ = "0.14.dev0"
__author__ = "orix developers"
__author_email__ = "pyxem.team@gmail.com"
__description__ = "orix is an open-source Python library for handling crystal orientation mapping data."
Expand Down
2 changes: 1 addition & 1 deletion orix/tests/plot/test_crystal_map_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def test_status_bar_silence_default_format_coord(self, crystal_map):
fig = plt.figure()
ax = fig.add_subplot(projection=PLOT_MAP)
_ = ax.plot_map(crystal_map)
assert ax.format_coord(0, 0) == "x=0 y=0"
assert ax.format_coord(0, 0) == "(x, y) = (0, 0)"

fig = plt.figure()
ax = fig.add_subplot(projection=PLOT_MAP)
Expand Down
165 changes: 81 additions & 84 deletions orix/tests/plot/test_rotation_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,87 +25,84 @@
from orix.quaternion.symmetry import C1, D6


def test_init_rodrigues_plot():
fig = plt.figure()
ax = fig.add_subplot(projection="rodrigues", auto_add_to_figure=False)
assert isinstance(ax, RodriguesPlot)


def test_init_axangle_plot():
fig = plt.figure()
ax = fig.add_subplot(projection="axangle", auto_add_to_figure=False)
assert isinstance(ax, AxAnglePlot)


def test_RotationPlot_methods():
"""This code is lifted from demo-3-v0.1."""
misori = Misorientation([1, 1, 1, 1]) # any will do
ori = Orientation.random()
fig = plt.figure()
ax = fig.add_subplot(
projection="axangle", proj_type="ortho", auto_add_to_figure=False
)
ax.scatter(misori)
ax.scatter(ori)
ax.plot(misori)
ax.plot(ori)
ax.plot_wireframe(OrientationRegion.from_symmetry(D6, D6))
plt.close("all")

# Clear the edge case
ax.transform(np.asarray([1, 1, 1]))


def test_full_region_plot():
empty = OrientationRegion.from_symmetry(C1, C1)
_ = empty.get_plot_data()


def test_RotationPlot_transform_fundamental_zone_raises():
fig = plt.figure()
ax = RotationPlot(fig)
fig.add_axes(ax)
with pytest.raises(
TypeError, match="fundamental_zone is not an OrientationRegion object"
):
ax.transform(Orientation.random(), fundamental_zone=1)


def test_RotationPlot_map_into_symmetry_reduced_zone():
# orientations are (in, out) of D6 fundamental zone
ori = Orientation(((1, 0, 0, 0), (0.5, 0.5, 0.5, 0.5)))
ori.symmetry = D6
fz = OrientationRegion.from_symmetry(ori.symmetry)
assert np.allclose(ori < fz, (True, False))
# test map_into_symmetry_reduced_zone in RotationPlot.transform
fig = ori.scatter(return_figure=True)
xyz_symmetry = fig.axes[0].collections[1]._offsets3d
# compute same plot again but with C1 symmetry where both orientations are in C1 FZ
ori.symmetry = C1
fig2 = ori.scatter(return_figure=True)
xyz = fig2.axes[0].collections[1]._offsets3d
# test that the plotted points are not the same
assert not np.allclose(xyz_symmetry, xyz)


def test_correct_aspect_ratio():
# Set up figure the "old" way
fig = plt.figure()
ax = fig.add_subplot(
projection="axangle", proj_type="ortho", auto_add_to_figure=False
)

# Check aspect ratio
x_old, _, z_old = ax.get_box_aspect()
assert np.allclose(x_old / z_old, 1.334, atol=1e-3)

fr = OrientationRegion.from_symmetry(D6)
ax._correct_aspect_ratio(fr, set_limits=False)

x_new, _, z_new = ax.get_box_aspect()
assert np.allclose(x_new / z_new, 3, atol=1e-3)

# Check data limits
assert np.allclose(ax.get_xlim(), [0, 1])
ax._correct_aspect_ratio(fr) # set_limits=True is default
assert np.allclose(ax.get_xlim(), [-np.pi / 2, np.pi / 2])
class TestRodriguesPlot:
def test_creation(self):
fig = plt.figure()
ax = fig.add_subplot(projection="rodrigues")
assert isinstance(ax, RodriguesPlot)


class TestAxisAnglePlot:
def test_creation(self):
fig = plt.figure()
ax = fig.add_subplot(projection="axangle")
assert isinstance(ax, AxAnglePlot)

plt.close("all")

def test_rotation_plot(self):
M = Misorientation.random()
O = Orientation.random()
fig = plt.figure()
ax = fig.add_subplot(projection="axangle", proj_type="ortho")
ax.scatter(M)
ax.scatter(O)
ax.plot(M)
ax.plot(O)
ax.plot_wireframe(OrientationRegion.from_symmetry(D6, D6))

ax.transform(np.asarray([1, 1, 1])) # Edge case

plt.close("all")

def test_get_plot_data(self):
empty = OrientationRegion.from_symmetry(C1, C1)
_ = empty.get_plot_data()

def test_rotation_plot_transform_fundamental_zone_raises(self):
fig = plt.figure()
ax = RotationPlot(fig)
fig.add_axes(ax)
with pytest.raises(TypeError, match="fundamental_zone is not an "):
ax.transform(Orientation.random(), fundamental_zone=1)

def test_rotation_plot_map_into_symmetry_reduced_zone(self):
# Orientations are (in, out) of D6 fundamental zone
O = Orientation(((1, 0, 0, 0), (0.5, 0.5, 0.5, 0.5)))
O.symmetry = D6
fz = OrientationRegion.from_symmetry(O.symmetry)
assert np.allclose(O < fz, (True, False))

# test map_into_symmetry_reduced_zone in RotationPlot.transform
fig = O.scatter(return_figure=True)
xyz_symmetry = fig.axes[0].collections[1]._offsets3d

# compute same plot again but with C1 symmetry where both orientations are in C1 FZ
O.symmetry = C1
fig2 = O.scatter(return_figure=True)
xyz = fig2.axes[0].collections[1]._offsets3d

# test that the plotted points are not the same
assert not np.allclose(xyz_symmetry, xyz)

plt.close("all")

def test_correct_aspect_ratio(self):
fig = plt.figure()
ax = fig.add_subplot(projection="axangle", proj_type="ortho")

# Check aspect ratio
x_old, _, z_old = ax.get_box_aspect()
assert np.allclose(x_old / z_old, 1.334, atol=1e-3)

fr = OrientationRegion.from_symmetry(D6)
ax._correct_aspect_ratio(fr, set_limits=False)

x_new, _, z_new = ax.get_box_aspect()
assert np.allclose(x_new / z_new, 3, atol=1e-3)

assert np.allclose(ax.get_xlim(), [0, 1], atol=0.1)
ax._correct_aspect_ratio(fr) # set_limits=True is default
assert np.allclose(ax.get_xlim(), [-np.pi / 2, np.pi / 2])

plt.close("all")
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
"numpy",
"numpy-quaternion",
"pooch >= 0.13",
# TODO: Remove once https://github.com/diffpy/diffpy.structure/issues/97 is fixed
"pycifrw",
"scipy",
"tqdm",
],
Expand Down

0 comments on commit b327412

Please sign in to comment.