import numpy as np

from warp_md.analysis.crank import crank


def test_crank_distance():
    a = np.array([1.0, 2.0, 3.0])
    b = np.array([2.5, 1.0, 3.5])
    out = crank(a, b, mode="distance")
    assert np.allclose(out, b - a)


def test_crank_angle_wrap():
    a = np.array([170.0, -170.0, 10.0])
    b = np.array([-170.0, 170.0, -170.0])
    out = crank(a, b, mode="angle")
    assert np.all(out <= 180.0)
    assert np.all(out >= -180.0)
