def test_calculating_norm_of_direct_lattice_vector(self, mocker): lattice = mocker.MagicMock(metric=CALCITE_DIRECT_METRIC) vector_1 = DirectLatticeVector([1, 1, 0], lattice) vector_2 = DirectLatticeVector([1, 2, 3], lattice) assert_almost_equal(vector_1.norm(), 4.99) assert_almost_equal(vector_2.norm(), 51.7330874)
def test_lattice_attribute_persists_when_new_array_created(self, mocker): lattice = mocker.MagicMock() vector_1 = DirectLatticeVector([1, 0, 0], lattice) vector_2 = 2 * vector_1 vector_3 = vector_1.copy() assert vector_2.lattice == lattice assert vector_3.lattice == lattice
def test_calculating_angle_between_two_vectors(self, mocker, uvw, result): lattice = mocker.MagicMock(metric=CALCITE_DIRECT_METRIC) vector_1 = DirectLatticeVector([1, 1, 1], lattice) vector_2 = DirectLatticeVector(uvw, lattice) assert_almost_equal(vector_1.angle(vector_2), result)
def test_calculating_inner_product_of_vectors(self, mocker, uvw, result): lattice = mocker.MagicMock(metric=CALCITE_DIRECT_METRIC) vector_1 = DirectLatticeVector([1, 1, 1], lattice) vector_2 = DirectLatticeVector(uvw, lattice) assert_almost_equal(vector_1.inner(vector_2), result)