How to use orix - 10 common examples

To help you get started, we’ve selected a few orix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / orix / tests / test_quaternion.py View on Github external
def test_init(input_length):
    with pytest.raises(DimensionError):
        Quaternion(tuple(range(input_length)))
github pyxem / orix / tests / test_rotation.py View on Github external
def test_mul_rotation(r1, i1, r2, i2, expected, expected_i):
    r1 = Rotation(r1)
    r1.improper = i1
    r2 = Rotation(r2)
    r2.improper = i2
    r = r1 * r2
    assert isinstance(r, Rotation)
    assert np.allclose(r.data, expected)
    assert np.all(r.improper == expected_i)
github pyxem / orix / tests / test_rotation.py View on Github external
import itertools

from orix.quaternion import Quaternion
from orix.quaternion.rotation import Rotation
from orix.vector import Vector3d

rotations = [
    (0.707, 0., 0., 0.707),
    (0.5, -0.5, -0.5, 0.5),
    (0., 0., 0., 1.),
    (1., 1., 1., 1.),
    (
        (0.5, -0.5, -0.5, 0.5),
        (0., 0., 0., 1.),
    ),
    Rotation([
        (2, 4, 6, 8),
        (-1, -2, -3, -4)
    ]),
    np.array((4, 3, 2, 1))
]

quaternions = [
    (0.881, 0.665, 0.123, 0.517),
    (0.111, 0.222, 0.333, 0.444),
    (
        (1, 0, 0.5, 0),
        (3, 1, -1, -2),
    ),
    [
        [[0.343, 0.343, 0, -0.333], [-7, -8, -9, -10],],
        [[0.00001, -0.0001, 0.001, -0.01], [0, 0, 0, 0]]
github pyxem / orix / tests / test_vector3d.py View on Github external
        Vector3d([[1, 2, 3], [-3, -2, -1]]),
        [[0, 0, 0], [4, 4, 4]],
        marks=pytest.mark.xfail(raises=ValueError)
    ),
    ([1, 2, 3], Scalar([4]), [4, 8, 12]),
    ([1, 2, 3], 0.5, [0.5, 1., 1.5]),
    ([1, 2, 3], [-1, 2], [[-1, -2, -3], [2, 4, 6]]),
    ([1, 2, 3], np.array([-1, 1]), [[-1, -2, -3], [1, 2, 3]]),
    pytest.param([1, 2, 3], 'dracula', None, marks=pytest.mark.xfail),
], indirect=['vector'])
def test_mul(vector, other, expected):
    s1 = vector * other
    s2 = other * vector
    assert np.allclose(s1.data, expected)
    assert np.allclose(s1.data, s2.data)
github pyxem / orix / tests / test_vector3d.py View on Github external
    ([1, 2, 3], Vector3d([[1, 2, 3], [-3, -2, -1]]), [[0, 0, 0], [4, 4, 4]]),
    ([1, 2, 3], Scalar([4]), [-3, -2, -1]),
    ([1, 2, 3], 0.5, [0.5, 1.5, 2.5]),
    ([1, 2, 3], [-1, 2], [[2, 3, 4], [-1, 0, 1]]),
    ([1, 2, 3], np.array([-1, 1]), [[2, 3, 4], [0, 1, 2]]),
    pytest.param([1, 2, 3], 'dracula', None, marks=pytest.mark.xfail),
], indirect=['vector'])
def test_sub(vector, other, expected):
    s1 = vector - other
    s2 = other - vector
    assert np.allclose(s1.data, expected)
    assert np.allclose(-s1.data, s2.data)
github pyxem / orix / tests / test_rotation.py View on Github external
def vector(request):
    return Vector3d(request.param)
github pyxem / orix / tests / test_spherical_region.py View on Github external
def vector(request):
    return Vector3d(request.param)
github pyxem / orix / tests / test_scalar.py View on Github external
    ([5], Scalar([6]), 0),
    pytest.param([3], 'larry', None, marks=pytest.mark.xfail),
], indirect=['scalar'])
def test_equality(scalar, other, expected):
    eq = scalar == other
    assert np.allclose(eq, expected)
github pyxem / orix / tests / test_vector3d.py View on Github external
def scalar(request):
    return Scalar(request.param)
github pyxem / orix / tests / test_quaternion.py View on Github external
def something(request):
    return Quaternion(request.param)