-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
66 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 The pyXem developers | ||
# | ||
# This file is part of pyXem. | ||
# | ||
# pyXem is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# pyXem is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with pyXem. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from diffsims.utils.vector_utils import get_angle_cartesian | ||
from diffsims.utils.vector_utils import get_angle_cartesian_vec | ||
|
||
|
||
@pytest.mark.parametrize('vec_a, vec_b, expected_angle', [ | ||
([0, 0, 1], [0, 1, 0], np.deg2rad(90)), | ||
([0, 0, 0], [0, 0, 1], 0) | ||
]) | ||
def test_get_angle_cartesian(vec_a, vec_b, expected_angle): | ||
angle = get_angle_cartesian(vec_a, vec_b) | ||
np.testing.assert_allclose(angle, expected_angle) | ||
|
||
|
||
@pytest.mark.parametrize('a, b, expected_angles', [ | ||
(np.array([[0, 0, 1], [0, 0, 0]]), np.array([[0, 1, 0], [0, 0, 1]]), [np.deg2rad(90), 0]) | ||
]) | ||
def test_get_angle_cartesian_vec(a, b, expected_angles): | ||
angles = get_angle_cartesian_vec(a, b) | ||
np.testing.assert_allclose(angles, expected_angles) | ||
|
||
|
||
@pytest.mark.xfail(raises=ValueError) | ||
def test_get_angle_cartesian_vec_input_validation(): | ||
get_angle_cartesian_vec(np.empty((2, 3)), np.empty((5, 3))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.